Get rid of the "Did not get proper search result" message. This helps with buggy IMAP servers that don't return an untagged SEARCH response if nothing was found. Other untagged responses are simply ignored.

Fixes Issue 907
This commit is contained in:
cketti 2010-03-25 01:24:21 +00:00
parent 1516127b09
commit 938317e700
1 changed files with 7 additions and 9 deletions

View File

@ -912,24 +912,22 @@ public class ImapStore extends Store
ArrayList<Message> messages = new ArrayList<Message>(); ArrayList<Message> messages = new ArrayList<Message>();
try try
{ {
boolean gotSearchValues = false;
ArrayList<Integer> uids = new ArrayList<Integer>(); ArrayList<Integer> uids = new ArrayList<Integer>();
List<ImapResponse> responses = searcher.search(); // List<ImapResponse> responses = searcher.search(); //
for (ImapResponse response : responses) for (ImapResponse response : responses)
{ {
if (response.get(0).equals("SEARCH")) if (response.mTag == null)
{ {
gotSearchValues = true; if (response.get(0).equals("SEARCH"))
for (int i = 1, count = response.size(); i < count; i++)
{ {
uids.add(Integer.parseInt(response.getString(i))); for (int i = 1, count = response.size(); i < count; i++)
{
uids.add(Integer.parseInt(response.getString(i)));
}
} }
} }
} }
if (gotSearchValues == false)
{
throw new MessagingException("Did not get proper search response");
}
// Sort the uids in numerically ascending order // Sort the uids in numerically ascending order
Collections.sort(uids); Collections.sort(uids);
for (int i = 0, count = uids.size(); i < count; i++) for (int i = 0, count = uids.size(); i < count; i++)