Wolfgang Beikircher wrote:
> Hi there!
>
> I'm using JavaMail 1.4.2 and get an NullPointerException when I try to
> close a folder. This happens only after some hours of run time of my
> application. Therefore, I think it has something to do with the
> connection timeout to the server.
>
> This is the error stack:
>
> Caused by: java.lang.NullPointerException
> at com.sun.mail.iap.Protocol.command(Protocol.java:324)
> at
> com.sun.mail.imap.protocol.IMAPProtocol.logout(IMAPProtocol.java:311)
> at com.sun.mail.imap.IMAPStore.releaseProtocol(IMAPStore.java:944)
> at com.sun.mail.imap.IMAPFolder.releaseProtocol(IMAPFolder.java:2666)
> at com.sun.mail.imap.IMAPFolder.cleanup(IMAPFolder.java:1143)
> at com.sun.mail.imap.IMAPFolder.close(IMAPFolder.java:1132)
> at com.sun.mail.imap.IMAPFolder.close(IMAPFolder.java:1055)
> at com.sun.mail.imap.IMAPStore.cleanup(IMAPStore.java:1289)
> at com.sun.mail.imap.IMAPStore.handleResponse(IMAPStore.java:1509)
> at com.sun.mail.iap.Protocol.notifyResponseHandlers(Protocol.java:216)
> at
> com.sun.mail.imap.protocol.IMAPProtocol.logout(IMAPProtocol.java:316)
> at com.sun.mail.imap.IMAPStore.close(IMAPStore.java:1217)
> at
> org.zimbra.exchange.email.transport.ImapMailServerWrapper.releaseConnection(ImapMailServerWrapper.java:129)
> ... 7 more
You may be right about a timeout causing this problem, but I'm
struggling to see why a timeout would cause this NullPointerException.
The code in Protocol.java is:
public synchronized Response[] command(String command, Argument args) {
Vector v = new Vector();
boolean done = false;
String tag = null;
Response r = null;
// write the command
try {
tag = writeCommand(command, args);
} catch (LiteralException lex) {
v.addElement(lex.getResponse());
done = true;
} catch (Exception ex) {
// Convert this into a BYE response
v.addElement(Response.byeResponse(ex));
done = true;
}
while (!done) {
try {
r = readResponse();
} catch (IOException ioex) {
// convert this into a BYE response
r = Response.byeResponse(ioex);
} catch (ProtocolException pex) {
continue; // skip this response
}
v.addElement(r);
if (r.isBYE()) // shouldn't wait for command completion response
done = true;
// If this is a matching command completion response, we are done
if (r.isTagged() && r.getTag().equals(tag))
done = true;
}
Response[] responses = new Response[v.size()];
v.copyInto(responses); // <---- line 324
timestamp = System.currentTimeMillis();
return responses;
}
"v" can't be null. "responses" can't be null.
Even if one of the elements in v is null (which shouldn't happen),
that wouldn't cause the NullPointerException.
What am I missing?
===========================================================================
To unsubscribe, send email to
listserv@java... and include in the body
of the message "signoff JAVAMAIL-INTEREST". For general help, send email to
listserv@java... and include in the body of the message "help".
opensubscriber is not affiliated with the authors of this message nor responsible for its content.