9 Replies Latest reply on Feb 20, 2014 9:50 PM by Bill Shannon-Oracle

    IMAPFolder.close bug ?

    Hamit Hasanhocaoglu



      According to source, IMAPFolder.close() method uses examine() command. If server returns a NO | BAD to this examine command, a protocol exception is thrown and in catch block, the protocol is being disconnected, after which is given back to IMAPStore connection pool in the finally block. If this closed protocol connection is reused by another operation, that command fails with "socket closed" and converted to SyntheticBye which causes all store connections to be cleaned up.


      Is this a bug ?


      // If the expunge flag is set or we're open read-only we
           // can just close the folder, otherwise open it read-only
           // before closing, or unselect it if supported.
                          if (!expunge && mode == READ_WRITE) {
                              try {
                               if (protocol != null &&
                               else {
        if (protocol != null) {
           protocol.examine(fullName);  // ------------------------ if this examine fails
           if (protocol != null) // XXX - unnecessary?
                              } catch (ProtocolException pex2) { 
                                  if (protocol != null) /// ---------------------- here is the disconnect, causes the protocol object to be invalid
                          } else {
        if (protocol != null)
           } catch (ProtocolException pex) {
        throw new MessagingException(pex.getMessage(), pex);
           } finally {
        // cleanup if we haven't already
        if (opened)
           cleanup(true); /// -------------------------------- here invalid protocol is given back to IMAPStore in releaseProtocol()