classpath-inetlib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Classpath-inetlib] IMAP search problem with no matches:


From: Robert Mitchell
Subject: [Classpath-inetlib] IMAP search problem with no matches:
Date: Fri, 15 Apr 2005 14:58:13 -0500

IMAPConnection.search can give a null pointer exception if the IMAP server returns no matches.  The sequence involved is:
 
imap: > A8 SEARCH UNSEEN
imap: < * SEARCH
imap: < A8 OK SEARCH completed
 
The problem is that IMAPResponse.getText returns null on the first response.  To fix this I changed the following lines in IMAPConnection..search:
 
        if (response.isUntagged())
          {
            if (id == SEARCH)
              {
                String text = response.getText();
                try
                  {
to check if text is null before parsing it:
 
        if (response.isUntagged())
          {
            if (id == SEARCH)
              {
                String text = response.getText();
                if (text == null) continue;
                try
                  {
 
The "continue" operation may not be the best way to skip the parsing, but it works and made for the least number of lines changed.
 
Thanks,
Bob Mitchell.
 

reply via email to

[Prev in Thread] Current Thread [Next in Thread]