Repository: mercurial
Revision: 88
Author: Bill Shannon <bill.shannon_at_sun.com>
Date: 2008-11-05 19:24:23 UTC
Log Message:
-----------
IMAPStore.isConnected might return true even though not connected.
Removed separate tracking of "connected" flag, which was no longer
needed and was the source of this bug.
Reported by David Nault <dnault_at_mac.com>.
Modified Paths:
--------------
doc/release/CHANGES.txt
mail/src/main/java/com/sun/mail/imap/IMAPStore.java
Diffs:
-----
diff -r dc8ba0762a6d -r ddd93ca773df doc/release/CHANGES.txt
--- a/doc/release/CHANGES.txt Wed Nov 05 11:16:47 2008 -0800
+++ b/doc/release/CHANGES.txt Wed Nov 05 11:24:23 2008 -0800
@@ -48,6 +48,7 @@
<no id> fix possible NPE in MimeMessage if flags is not set in
copy constructor
<no id> SMTP I/O failure incorrectly reports valid sent
addresses
<no id> avoid creating IMAPMessage objects until they're
actually needed
+<no id> IMAPStore.isConnected might return true even though not
connected
CHANGES IN THE 1.4.1 RELEASE
diff -r dc8ba0762a6d -r ddd93ca773df
mail/src/main/java/com/sun/mail/imap/IMAPStore.java
--- a/mail/src/main/java/com/sun/mail/imap/IMAPStore.java Wed Nov
05 11:16:47 2008 -0800
+++ b/mail/src/main/java/com/sun/mail/imap/IMAPStore.java Wed Nov
05 11:24:23 2008 -0800
@@ -186,12 +186,6 @@
private boolean forcePasswordRefresh = false;
// enable notification of IMAP responses
private boolean enableImapEvents = false;
-
- /*
- * Track our connected state. Set on successful return from
- * protocolConnect and reset in cleanup.
- */
- private boolean connected = false;
/*
* This field is set in the Store's response handler if we see
@@ -614,9 +608,7 @@
throw new MessagingException(ioex.getMessage(), ioex);
}
- connected = true;
return true;
-
}
private void login(IMAPProtocol p, String u, String pw)
@@ -1234,10 +1226,9 @@
* method, to actually ping our server connection.
*/
public synchronized boolean isConnected() {
- if (!connected) {
+ if (!super.isConnected()) {
// if we haven't been connected at all, don't bother with
// the NOOP.
- super.setConnected(false); // just in case
return false;
}
@@ -1347,7 +1338,7 @@
*/
private synchronized void cleanup() {
// if we're not connected, someone beat us to it
- if (!connected) {
+ if (!super.isConnected()) {
if (debug)
out.println("DEBUG: IMAPStore cleanup, not connected");
return;
@@ -1423,8 +1414,10 @@
emptyConnectionPool(force);
}
- connected = false;
- notifyConnectionListeners(ConnectionEvent.CLOSED);
+ // to set the state and send the closed connection event
+ try {
+ super.close();
+ } catch (MessagingException mex) { }
if (debug)
out.println("DEBUG: IMAPStore cleanup done");
}
@@ -1598,10 +1591,8 @@
private void checkConnected() {
assert Thread.holdsLock(this);
- if (!connected) {
- super.setConnected(false); // just in case
+ if (!super.isConnected())
throw new IllegalStateException("Not connected");
- }
}
/**