Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

IMAPFolder.close bug ?

Hamit HasanhocaogluJan 22 2014 — edited Feb 20 2014

Hi;

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 &&

                              protocol.hasCapability("UNSELECT"))

                          protocol.unselect();

                         else {

  if (protocol != null) {

     protocol.examine(fullName);  // ------------------------ if this examine fails

     if (protocol != null) // XXX - unnecessary?

  protocol.close();

  }

     }

                        } catch (ProtocolException pex2) {

                            if (protocol != null) /// ---------------------- here is the disconnect, causes the protocol object to be invalid

  protocol.disconnect();

                        }

                    } else {

  if (protocol != null)

     protocol.close();

     }

                }

     } 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()

     }

Comments

Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Mar 20 2014
Added on Jan 22 2014
9 comments
3,570 views