Repository: mercurial
Revision: 138
Author: Bill Shannon <bill.shannon_at_sun.com>
Date: 2009-05-06 23:44:46 UTC
Link:
http://kenai.com/projects/javamail/sources/mercurial/revision/138
Log Message:
-----------
Check whether UIDL is supported before using it.
Make POP3Store fields volatile if accessed by other classes.
Modified Paths:
--------------
mail/src/main/java/com/sun/mail/pop3/POP3Folder.java
mail/src/main/java/com/sun/mail/pop3/POP3Store.java
Diffs:
-----
diff -r 7f8a6c2be5dc -r 77e63f5e61ba
mail/src/main/java/com/sun/mail/pop3/POP3Folder.java
--- a/mail/src/main/java/com/sun/mail/pop3/POP3Folder.java Wed May
06 16:22:07 2009 -0700
+++ b/mail/src/main/java/com/sun/mail/pop3/POP3Folder.java Wed May
06 16:44:46 2009 -0700
@@ -1,7 +1,7 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 1997-2009 Sun Microsystems, Inc. All rights reserved.
*
* The contents of this file are subject to the terms of either the
GNU
* General Public License Version 2 only ("GPL") or the Common
Development
@@ -362,7 +362,8 @@
public synchronized void fetch(Message[] msgs, FetchProfile fp)
throws MessagingException {
checkReadable();
- if (!doneUidl && fp.contains(UIDFolder.FetchProfileItem.UID)) {
+ if (!doneUidl && ((POP3Store)store).supportsUidl &&
+ fp.contains(UIDFolder.FetchProfileItem.UID)) {
/*
* Since the POP3 protocol only lets us fetch the UID
* for a single message or for all messages, we go ahead
@@ -415,6 +416,8 @@
checkOpen();
POP3Message m = (POP3Message)msg;
try {
+ if (!((POP3Store)store).supportsUidl)
+ return null;
if (m.uid == POP3Message.UNKNOWN)
m.uid = port.uidl(m.getMessageNumber());
return m.uid;
diff -r 7f8a6c2be5dc -r 77e63f5e61ba
mail/src/main/java/com/sun/mail/pop3/POP3Store.java
--- a/mail/src/main/java/com/sun/mail/pop3/POP3Store.java Wed May
06 16:22:07 2009 -0700
+++ b/mail/src/main/java/com/sun/mail/pop3/POP3Store.java Wed May
06 16:44:46 2009 -0700
@@ -69,13 +69,16 @@
private int portNum = -1;
private String user = null;
private String passwd = null;
- boolean rsetBeforeQuit = false;
- boolean disableTop = false;
- boolean forgetTopHeaders = false;
- boolean useStartTLS = false;
- boolean requireStartTLS = false;
- Map capabilities;
- Constructor messageConstructor = null;
+ private boolean useStartTLS = false;
+ private boolean requireStartTLS = false;
+ private Map capabilities;
+
+ // following set here and accessed by other classes in this
package
+ volatile Constructor messageConstructor = null;
+ volatile boolean rsetBeforeQuit = false;
+ volatile boolean disableTop = false;
+ volatile boolean forgetTopHeaders = false;
+ volatile boolean supportsUidl = true;
public POP3Store(Session session, URLName url) {
this(session, url, "pop3", false);
@@ -260,6 +263,8 @@
"DEBUG POP3: server doesn't support TOP, disabling
it");
}
+ supportsUidl = capabilities == null ||
capabilities.containsKey("UIDL");
+
String msg = null;
if ((msg = p.login(user, passwd)) != null) {
try {
@@ -340,8 +345,9 @@
* @since JavaMail 1.4.3
*/
public Map capabilities() throws MessagingException {
- if (capabilities != null)
- return Collections.unmodifiableMap(capabilities);
+ Map c = capabilities; // atomic read of pointer
+ if (c != null)
+ return Collections.unmodifiableMap(c);
else
return Collections.emptyMap();
}