Project: javamail
Repository: mercurial
Revision: 585
Author: shannon
Date: 2013-07-19 20:52:46 UTC
Link:
Log Message:
------------
Make sure there really is a sender in the envelope - bug 5989
Changed the writeToFile method, used by appendMessages, to not use the
MboxMessage.writeTo method, which sets the SEEN flag.
This was a particular problem when my mail filter appended a newly arrived
and filtered message to my INBOX.
Update a few more references to RFC 2822.
Fix or exclude a bunch of FindBugs errors.
Upgrade to the latest version of the FindBugs plugin.
handle an empty charset in an RFC 2231 encoded parameter - bug 6004
Oops, forgot to update CHANGES.txt.
Revisions:
----------
580
581
582
583
584
585
Modified Paths:
---------------
doc/release/CHANGES.txt
mail/src/main/java/com/sun/mail/imap/IMAPMessage.java
mbox/src/main/java/com/sun/mail/mbox/MboxMessage.java
mail/src/main/java/javax/mail/internet/MailDateFormat.java
dsn/src/main/java/com/sun/mail/dsn/text_rfc822headers.java
gimap/pom.xml
gimap/src/main/java/com/sun/mail/gimap/GmailMessage.java
gimap/src/main/java/com/sun/mail/gimap/GmailMsgIdTerm.java
gimap/src/main/java/com/sun/mail/gimap/GmailThrIdTerm.java
gimap/src/main/java/com/sun/mail/gimap/protocol/GmailProtocol.java
mail/exclude.xml
mail/src/main/java/com/sun/mail/auth/Ntlm.java
mail/src/main/java/com/sun/mail/handlers/text_plain.java
mail/src/main/java/com/sun/mail/handlers/text_xml.java
mail/src/main/java/com/sun/mail/iap/Argument.java
mail/src/main/java/com/sun/mail/iap/ResponseInputStream.java
mail/src/main/java/com/sun/mail/imap/IMAPFolder.java
mail/src/main/java/com/sun/mail/imap/IMAPStore.java
mail/src/main/java/com/sun/mail/imap/protocol/ENVELOPE.java
mail/src/main/java/com/sun/mail/imap/protocol/IMAPProtocol.java
mail/src/main/java/com/sun/mail/imap/protocol/SearchSequence.java
mail/src/main/java/com/sun/mail/pop3/POP3Folder.java
mail/src/main/java/com/sun/mail/pop3/POP3Message.java
mail/src/main/java/com/sun/mail/pop3/POP3Store.java
mail/src/main/java/com/sun/mail/pop3/Protocol.java
mail/src/main/java/com/sun/mail/smtp/DigestMD5.java
mail/src/main/java/com/sun/mail/smtp/SMTPTransport.java
mail/src/main/java/com/sun/mail/util/SocketConnectException.java
mail/src/main/java/com/sun/mail/util/SocketFetcher.java
mail/src/main/java/javax/mail/Message.java
mail/src/main/java/javax/mail/Session.java
mail/src/main/java/javax/mail/internet/HeaderTokenizer.java
mail/src/main/java/javax/mail/internet/InternetHeaders.java
mail/src/main/java/javax/mail/internet/ParameterList.java
mail/src/main/java/javax/mail/search/BodyTerm.java
mail/src/main/java/javax/mail/search/FlagTerm.java
mbox/exclude.xml
mbox/src/main/java/com/sun/mail/mbox/MboxFolder.java
mbox/src/main/java/com/sun/mail/mbox/MessageLoader.java
mbox/src/main/java/com/sun/mail/mbox/SunV3BodyPart.java
mbox/src/main/java/com/sun/mail/mbox/SunV3Multipart.java
pom.xml
mail/src/test/resources/javax/mail/internet/paramdata
Added Paths:
------------
gimap/exclude.xml
Diffs:
------
diff -r b937e559a8ce -r a453d7d584db doc/release/CHANGES.txt
--- a/doc/release/CHANGES.txt Fri Jun 21 17:14:03 2013 -0700
+++ b/doc/release/CHANGES.txt Mon Jun 24 14:44:55 2013 -0700
@@ -24,6 +24,7 @@
K 5934 method fill() isn't synchronized correctly in SharedFileInputStream
K 5978 NullPointerException in MimeUtility#quote()
K 5987 support RFC 2359 COPYUID response code
+K 5989 Empty FROM Field causes Exception
CHANGES IN THE 1.5.0 RELEASE
diff -r b937e559a8ce -r a453d7d584db mail/src/main/java/com/sun/mail/imap/IMAPMessage.java
--- a/mail/src/main/java/com/sun/mail/imap/IMAPMessage.java Fri Jun 21 17:14:03 2013 -0700
+++ b/mail/src/main/java/com/sun/mail/imap/IMAPMessage.java Mon Jun 24 14:44:55 2013 -0700
@@ -325,7 +325,7 @@
public Address getSender() throws MessagingException {
checkExpunged();
loadEnvelope();
- if (envelope.sender != null)
+ if (envelope.sender != null && envelope.sender.length > 0)
return (envelope.sender)[0]; // there can be only one sender
else
return null;
diff -r a453d7d584db -r a81bfd74f5a7 mbox/src/main/java/com/sun/mail/mbox/MboxMessage.java
--- a/mbox/src/main/java/com/sun/mail/mbox/MboxMessage.java Mon Jun 24 14:44:55 2013 -0700
+++ b/mbox/src/main/java/com/sun/mail/mbox/MboxMessage.java Fri Jun 28 21:35:01 2013 -0700
@@ -1,7 +1,7 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2013 Oracle and/or its affiliates. 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
@@ -469,7 +469,7 @@
*/
ContentLengthCounter cos = new ContentLengthCounter();
OutputStream oos = new NewlineOutputStream(cos);
- super.writeTo(oos);
+ super.writeTo(oos, null);
oos.flush();
setHeader("Content-Length", String.valueOf(cos.getSize()));
// setContentSize((int)cos.getSize());
@@ -479,7 +479,7 @@
PrintStream pos = new PrintStream(os, false, "iso-8859-1");
pos.println(unix_from);
- super.writeTo(pos);
+ super.writeTo(pos, null);
pos.println(); // make sure there's a blank line at the end
pos.flush();
} catch (MessagingException e) {
diff -r a81bfd74f5a7 -r a94c3ccad618 mail/src/main/java/javax/mail/internet/MailDateFormat.java
--- a/mail/src/main/java/javax/mail/internet/MailDateFormat.java Fri Jun 28 21:35:01 2013 -0700
+++ b/mail/src/main/java/javax/mail/internet/MailDateFormat.java Wed Jul 03 16:20:29 2013 -0700
@@ -146,7 +146,7 @@
/**
* Formats the given date in the format specified by
- * draft-ietf-drums-msg-fmt-08 in the current TimeZone.
+ * RFC 2822 in the current TimeZone.
*
* @param date the Date object
* @param dateStrBuf the formatted string
@@ -202,7 +202,7 @@
/**
* Parses the given date in the format specified by
- * draft-ietf-drums-msg-fmt-08 in the current TimeZone.
+ * RFC 2822 in the current TimeZone.
*
* @param text the formatted date to be parsed
* @param pos the current parse position
diff -r a94c3ccad618 -r fcd7d08a790e dsn/src/main/java/com/sun/mail/dsn/text_rfc822headers.java
--- a/dsn/src/main/java/com/sun/mail/dsn/text_rfc822headers.java Wed Jul 03 16:20:29 2013 -0700
+++ b/dsn/src/main/java/com/sun/mail/dsn/text_rfc822headers.java Wed Jul 03 17:25:42 2013 -0700
@@ -1,7 +1,7 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2010 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2013 Oracle and/or its affiliates. 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
@@ -142,7 +142,9 @@
} finally {
try {
is.close();
- } catch (IOException ex) { }
+ } catch (IOException ex) {
+ // ignore it
+ }
}
}
diff -r a94c3ccad618 -r fcd7d08a790e gimap/exclude.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gimap/exclude.xml Wed Jul 03 17:25:42 2013 -0700
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+
+ Copyright (c) 2013 Oracle and/or its affiliates. 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
+ and Distribution License("CDDL") (collectively, the "License"). You
+ may not use this file except in compliance with the License. You can
+ obtain a copy of the License at
+
https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
+ or packager/legal/LICENSE.txt. See the License for the specific
+ language governing permissions and limitations under the License.
+
+ When distributing the software, include this License Header Notice in each
+ file and include the License file at packager/legal/LICENSE.txt.
+
+ GPL Classpath Exception:
+ Oracle designates this particular file as subject to the "Classpath"
+ exception as provided by Oracle in the GPL Version 2 section of the License
+ file that accompanied this code.
+
+ Modifications:
+ If applicable, add the following below the License Header, with the fields
+ enclosed by brackets [] replaced by your own identifying information:
+ "Portions Copyright [year] [name of copyright owner]"
+
+ Contributor(s):
+ If you wish your version of this file to be governed by only the CDDL or
+ only the GPL Version 2, indicate your decision by adding "[Contributor]
+ elects to include this software in this distribution under the [CDDL or GPL
+ Version 2] license." If you don't indicate a single choice of license, a
+ recipient has the option to distribute your version of this file under
+ either the CDDL, the GPL Version 2 or to extend the choice of license to
+ its licensees as provided above. However, if you add GPL Version 2 code
+ and therefore, elected the GPL Version 2 license, then the option applies
+ only if the new code is made subject to such option by the copyright
+ holder.
+
+-->
+
+<!-- FindBugs exclude list for JavaMail gimap provider -->
+
+<FindBugsFilter>
+ <!--
+ These returned arrays are never exposed to applications so it's
+ safe that it doesn't return a copy.
+ -->
+ <Match>
+ <Class name="com.sun.mail.gimap.protocol.GmailProtocol"/>
+ <Method name="getFetchItems"/>
+ <Bug pattern="EI_EXPOSE_REP"/>
+ </Match>
+
+</FindBugsFilter>
diff -r a94c3ccad618 -r fcd7d08a790e gimap/pom.xml
--- a/gimap/pom.xml Wed Jul 03 16:20:29 2013 -0700
+++ b/gimap/pom.xml Wed Jul 03 17:25:42 2013 -0700
@@ -60,6 +60,9 @@
<mail.packages.export>
com.sun.mail.gimap; version=${mail.version}
</mail.packages.export>
+ <findbugs.exclude>
+ ${project.basedir}/exclude.xml
+ </findbugs.exclude>
</properties>
<build>
@@ -75,7 +78,7 @@
<configuration>
<skip>false</skip>
<threshold>${findbugs.threshold}</threshold>
- <excludeFilterFile>exclude.xml</excludeFilterFile>
+ <excludeFilterFile>${findbugs.exclude}</excludeFilterFile>
<findbugsXmlWithMessages>true</findbugsXmlWithMessages>
</configuration>
</plugin>
diff -r a94c3ccad618 -r fcd7d08a790e gimap/src/main/java/com/sun/mail/gimap/GmailMessage.java
--- a/gimap/src/main/java/com/sun/mail/gimap/GmailMessage.java Wed Jul 03 16:20:29 2013 -0700
+++ b/gimap/src/main/java/com/sun/mail/gimap/GmailMessage.java Wed Jul 03 17:25:42 2013 -0700
@@ -97,13 +97,15 @@
/**
* Return the Gmail labels associated with this message.
+ *
+ * @return array of labels, or empty array if none
*/
public String[] getLabels() throws MessagingException {
String[] labels = (String[])getItem(GmailProtocol.LABELS_ITEM);
if (labels != null)
return (String[])(labels.clone());
else
- return null;
+ return new String[0];
}
}
diff -r a94c3ccad618 -r fcd7d08a790e gimap/src/main/java/com/sun/mail/gimap/GmailMsgIdTerm.java
--- a/gimap/src/main/java/com/sun/mail/gimap/GmailMsgIdTerm.java Wed Jul 03 16:20:29 2013 -0700
+++ b/gimap/src/main/java/com/sun/mail/gimap/GmailMsgIdTerm.java Wed Jul 03 17:25:42 2013 -0700
@@ -1,7 +1,7 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2013 Oracle and/or its affiliates. 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
@@ -73,7 +73,10 @@
long msgId;
try {
- msgId = ((GmailMessage)msg).getMsgId();
+ if (msg instanceof GmailMessage)
+ msgId = ((GmailMessage)msg).getMsgId();
+ else
+ return false;
} catch (Exception e) {
return false;
}
diff -r a94c3ccad618 -r fcd7d08a790e gimap/src/main/java/com/sun/mail/gimap/GmailThrIdTerm.java
--- a/gimap/src/main/java/com/sun/mail/gimap/GmailThrIdTerm.java Wed Jul 03 16:20:29 2013 -0700
+++ b/gimap/src/main/java/com/sun/mail/gimap/GmailThrIdTerm.java Wed Jul 03 17:25:42 2013 -0700
@@ -1,7 +1,7 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2013 Oracle and/or its affiliates. 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
@@ -66,14 +66,17 @@
/**
* The match method.
*
- * @param thr the Message number is matched with this Message
+ * @param msg the Message number is matched with this Message
* @return true if the match succeeds, otherwise false
*/
- public boolean match(Message thr) {
+ public boolean match(Message msg) {
long thrId;
try {
- thrId = ((GmailMessage)thr).getThrId();
+ if (msg instanceof GmailMessage)
+ thrId = ((GmailMessage)msg).getThrId();
+ else
+ return false;
} catch (Exception e) {
return false;
}
diff -r a94c3ccad618 -r fcd7d08a790e gimap/src/main/java/com/sun/mail/gimap/protocol/GmailProtocol.java
--- a/gimap/src/main/java/com/sun/mail/gimap/protocol/GmailProtocol.java Wed Jul 03 16:20:29 2013 -0700
+++ b/gimap/src/main/java/com/sun/mail/gimap/protocol/GmailProtocol.java Wed Jul 03 17:25:42 2013 -0700
@@ -64,13 +64,13 @@
public static final FetchItem MSGID_ITEM =
new FetchItem("X-GM-MSGID", FetchProfileItem.MSGID) {
public Object parseItem(FetchResponse r) {
- return new Long(r.readLong());
+ return Long.valueOf(r.readLong());
}
};
public static final FetchItem THRID_ITEM =
new FetchItem("X-GM-THRID", FetchProfileItem.THRID) {
public Object parseItem(FetchResponse r) {
- return new Long(r.readLong());
+ return Long.valueOf(r.readLong());
}
};
public static final FetchItem LABELS_ITEM =
diff -r a94c3ccad618 -r fcd7d08a790e mail/exclude.xml
--- a/mail/exclude.xml Wed Jul 03 16:20:29 2013 -0700
+++ b/mail/exclude.xml Wed Jul 03 17:25:42 2013 -0700
@@ -45,6 +45,20 @@
<FindBugsFilter>
<!--
+ FindBugs *really* wants us to use zero length arrays instead
+ of null. Unfortunately, there's a bunch of places we can't
+ do this for various reasons:
+ - The API specifies null and we can't make an incompatible change.
+ - We use null to indicate no header and an empty array to indicate
+ the header exists but has no entries.
+ - We use null to indicate NIL in the protocol and an empty array
+ to indicate an empty list "()" in the protocol.
+ This error occurs often enough that we just ignore it everywhere.
+ -->
+ <Match>
+ <Bug pattern="PZLA_PREFER_ZERO_LENGTH_ARRAYS"/>
+ </Match>
+ <!--
There are a bunch of places where FindBugs complains about
exposing internal representations. We exclude cases where
this only happens in internal classes that are never visible
@@ -56,10 +70,12 @@
-->
<Match>
<Or>
- <Class name="com.sun.mail.iap.ByteArray"/>
<Class name="javax.mail.SendFailedException"/>
<Class name="javax.mail.event.MessageCountEvent"/>
<Class name="javax.mail.event.TransportEvent"/>
+ <Class name="com.sun.mail.iap.ByteArray"/>
+ <Class name="com.sun.mail.imap.MessageVanishedEvent"/>
+ <Class name="com.sun.mail.imap.protocol.FetchResponse"/>
</Or>
<Or>
<Bug pattern="EI_EXPOSE_REP"/>
@@ -107,6 +123,11 @@
-->
<Bug pattern="EI_EXPOSE_REP"/>
</Match>
+ <Match>
+ <Class name="com.sun.mail.imap.CopyUID"/>
+ <Method name="<init>"/> <!-- match constructor -->
+ <Bug pattern="EI_EXPOSE_REP2"/>
+ </Match>
<!--
A few places where it complains about wait not being in a loop.
@@ -130,15 +151,28 @@
explicitly thrown. We need to make sure that if anything
goes wrong we clean things up. Perhaps these should be
converted to a finally block and a boolean "success" flag?
+ Most of these are related to reflection or ClassLoader
+ operations, which can fail for all sorts of unexpected reasons.
+ Some of these could be converted to use multi-catch with JDK 1.7.
-->
<Match>
<Class name="com.sun.mail.imap.IMAPStore"/>
- <Method name="getProtocol"/>
+ <Or>
+ <Method name="<init>"/> <!-- match constructor -->
+ <Method name="getProtocol"/>
+ <Method name="getStoreProtocol"/>
+ <Method name="newIMAPFolder"/>
+ </Or>
<Bug pattern="REC_CATCH_EXCEPTION"/>
</Match>
<Match>
- <Class name="com.sun.mail.imap.IMAPStore"/>
- <Method name="getStoreProtocol"/>
+ <Class name="com.sun.mail.imap.protocol.IMAPProtocol"/>
+ <Or>
+ <Method name="authlogin"/>
+ <Method name="authntlm"/>
+ <Method name="authplain"/>
+ <Method name="sasllogin"/>
+ </Or>
<Bug pattern="REC_CATCH_EXCEPTION"/>
</Match>
<Match>
@@ -147,6 +181,19 @@
<Bug pattern="REC_CATCH_EXCEPTION"/>
</Match>
<Match>
+ <Class name="com.sun.mail.pop3.POP3Store"/>
+ <Method name="<init>"/> <!-- match constructor -->
+ <Bug pattern="REC_CATCH_EXCEPTION"/>
+ </Match>
+ <Match>
+ <Class name="com.sun.mail.smtp.SMTPTransport"/>
+ <Or>
+ <Method name="isConnected"/>
+ <Method name="sasllogin"/>
+ </Or>
+ <Bug pattern="REC_CATCH_EXCEPTION"/>
+ </Match>
+ <Match>
<Class name="com.sun.mail.pop3.POP3Folder"/>
<Method name="createMessage"/>
<Or>
@@ -156,12 +203,32 @@
</Match>
<Match>
<Class name="com.sun.mail.util.SocketFetcher"/>
- <Method name="startTLS"/>
+ <Or>
+ <Method name="getSocket"/>
+ <Method name="startTLS"/>
+ <Method name="matchCert"/>
+ </Or>
+ <Bug pattern="REC_CATCH_EXCEPTION"/>
+ </Match>
+ <Match>
+ <Class name="com.sun.mail.util.MimeUtil"/>
+ <Method name="cleanContentType"/>
<Bug pattern="REC_CATCH_EXCEPTION"/>
</Match>
<Match>
<Class name="javax.mail.Session"/>
- <Method name="loadAllResources"/>
+ <Or>
+ <Method name="getService"/>
+ <Method name="loadAllResources"/>
+ </Or>
+ <Bug pattern="REC_CATCH_EXCEPTION"/>
+ </Match>
+ <Match>
+ <Class name="javax.mail.internet.MimeUtility"/>
+ <Or>
+ <Method name="<clinit>"/> <!-- match static initializer -->
+ <Method name="getEncoding"/>
+ </Or>
<Bug pattern="REC_CATCH_EXCEPTION"/>
</Match>
@@ -231,7 +298,7 @@
about transient fields in subclasses. I don't know why it's
complaining about these fields but not others, but since I don't
really expect anyone to serialize these events I'm just ignoring
- this complaint.
+ this complaint. Ditto Exception fields.
-->
<Match>
<Class name="javax.mail.event.TransportEvent"/>
@@ -242,12 +309,47 @@
</Or>
<Bug pattern="SE_TRANSIENT_FIELD_NOT_RESTORED"/>
</Match>
+ <Match>
+ <Class name="javax.mail.event.FolderEvent"/>
+ <Or>
+ <Field name="folder"/>
+ <Field name="newFolder"/>
+ </Or>
+ <Bug pattern="SE_TRANSIENT_FIELD_NOT_RESTORED"/>
+ </Match>
+ <Match>
+ <Class name="javax.mail.event.MessageChangedEvent"/>
+ <Field name="msg"/>
+ <Bug pattern="SE_TRANSIENT_FIELD_NOT_RESTORED"/>
+ </Match>
+ <Match>
+ <Class name="javax.mail.event.MessageCountEvent"/>
+ <Field name="msgs"/>
+ <Bug pattern="SE_TRANSIENT_FIELD_NOT_RESTORED"/>
+ </Match>
+ <Match>
+ <Class name="javax.mail.event.TransportEvent"/>
+ <Field name="msg"/>
+ <Bug pattern="SE_TRANSIENT_FIELD_NOT_RESTORED"/>
+ </Match>
+ <Match>
+ <Class name="javax.mail.SendFailedException"/>
+ <Or>
+ <Field name="invalid"/>
+ <Field name="validSent"/>
+ <Field name="validUnsent"/>
+ </Or>
+ <Bug pattern="SE_TRANSIENT_FIELD_NOT_RESTORED"/>
+ </Match>
<!--
- This string comparison using == is just an optimization.
+ These string comparisons are just optimizations.
-->
<Match>
- <Class name="javax.mail.internet.InternetAddress"/>
+ <Or>
+ <Class name="javax.mail.URLName"/>
+ <Class name="javax.mail.internet.InternetAddress"/>
+ </Or>
<Method name="equals"/>
<Bug pattern="ES_COMPARING_STRINGS_WITH_EQ"/>
</Match>
@@ -424,4 +526,150 @@
<Bug pattern="IS2_INCONSISTENT_SYNC"/>
</Match>
+ <!--
+ Refactoring these anonymous inner classes to be static classes
+ makes the code less readable. Too bad there's no way for an
+ anonymous inner class to be static.
+ XXX - these class names aren't going to be stable as the code changes
+ -->
+ <Match>
+ <Or>
+ <Class name="com.sun.mail.imap.DefaultFolder$1"/>
+ <Class name="com.sun.mail.imap.DefaultFolder$2"/>
+ <Class name="com.sun.mail.imap.IMAPFolder$1"/>
+ <Class name="com.sun.mail.imap.IMAPFolder$4"/>
+ <Class name="com.sun.mail.imap.IMAPFolder$7"/>
+ <Class name="com.sun.mail.imap.IMAPFolder$13"/>
+ </Or>
+ <Bug pattern="SIC_INNER_SHOULD_BE_STATIC_ANON"/>
+ </Match>
+
+ <!--
+ Even though only this array reference is volatile, the array is
+ used in such a way that it's safe. The aray elements are created
+ and initialized before the array is assigned to this array
+ reference, and after being assigned neither the array nor the
+ array elements are changed.
+ -->
+ <Match>
+ <Class name="com.sun.mail.imap.IMAPFolder"/>
+ <Field name="attributes"/>
+ <Bug pattern="VO_VOLATILE_REFERENCE_TO_ARRAY"/>
+ </Match>
+
+ <!--
+ This code is easier to understand with empty "if" clauses;
+ the "match" method is being called for its side effects.
+ -->
+ <Match>
+ <Class name="com.sun.mail.imap.protocol.FetchResponse"/>
+ <Method name="parseItem"/>
+ <Bug pattern="UCF_USELESS_CONTROL_FLOW"/>
+ </Match>
+
+ <!--
+ Even though these fields are unread for now, we'll keep them
+ since they represent data in the protocol message being parsed.
+ -->
+ <Match>
+ <Or>
+ <Class name="com.sun.mail.imap.protocol.ENVELOPE"/>
+ <Class name="com.sun.mail.imap.protocol.INTERNALDATE"/>
+ <Class name="com.sun.mail.imap.protocol.RFC822SIZE"/>
+ </Or>
+ <Field name="msgno"/>
+ <Bug pattern="URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD"/>
+ </Match>
+ <Match>
+ <Class name="com.sun.mail.imap.protocol.MailboxInfo"/>
+ <Field name="first"/>
+ <Bug pattern="URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD"/>
+ </Match>
+ <!--
+ These unread fields are part of the public API.
+ -->
+ <Match>
+ <Class name="javax.mail.Service"/>
+ <Field name="debug"/>
+ <Bug pattern="URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD"/>
+ </Match>
+ <Match>
+ <Class name="javax.mail.Quota$Resource"/>
+ <Field name="usage"/>
+ <Bug pattern="URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD"/>
+ </Match>
+
+ <!--
+ We use a static MailDateFormat instance, which uses a static
+ GregorianCalendar instance. The MailDateFormat.parse method
+ uses only local data except for the GregorianCalendar instance,
+ which is invoked through a static synchronized method.
+ -->
+ <Match>
+ <Class name="com.sun.mail.imap.protocol.ENVELOPE"/>
+ <Bug pattern="STCAL_INVOKE_ON_STATIC_DATE_FORMAT_INSTANCE"/>
+ </Match>
+
+ <!--
+ A special String instance is used to indicate that the POP3
+ UID is unknown. The uid field is initialized to this String
+ instance, which we then compare with later to see if the uid
+ has been set.
+ -->
+ <Match>
+ <Class name="com.sun.mail.pop3.POP3Folder"/>
+ <Method name="getUID"/>
+ <Bug pattern="ES_COMPARING_STRINGS_WITH_EQ"/>
+ </Match>
+ <!--
+ As above, a special String instance is used to indicate whether
+ certain fields have been set.
+ -->
+ <Match>
+ <Class name="com.sun.mail.smtp.SMTPTransport"/>
+ <Or>
+ <Method name="getAuthorizationId"/>
+ <Method name="getNTLMDomain"/>
+ <Method name="getSASLRealm"/>
+ </Or>
+ <Bug pattern="ES_COMPARING_STRINGS_WITH_EQ"/>
+ </Match>
+
+ <!--
+ I know Exception.toString is never supposed to return null,
+ but this extra check is cheap insurance.
+ -->
+ <Match>
+ <Class name="javax.mail.MessagingException"/>
+ <Method name="toString"/>
+ <Bug pattern="RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE"/>
+ </Match>
+ <!--
+ I know ClassLoader.getResources is never supposed to return null,
+ but this extra check is cheap insurance.
+ -->
+ <Match>
+ <Class name="~javax\.mail\.Session\$.*"/>
+ <Method name="run"/>
+ <Bug pattern="RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE"/>
+ </Match>
+
+ <!--
+ These names may be confusing, but we're stuck with them.
+ -->
+ <Match>
+ <Class name="javax.mail.PasswordAuthentication"/>
+ <Method name="getUserName"/>
+ <Bug pattern="NM_CONFUSING"/>
+ </Match>
+
+ <!--
+ This trivial inner class extends ArrayList, but is never serialized,
+ so it doesn't really need a serialVersionUID.
+ -->
+ <Match>
+ <Class name="javax.mail.internet.ParameterList$MultiValue"/>
+ <Bug pattern="SE_NO_SERIALVERSIONID"/>
+ </Match>
+
</FindBugsFilter>
diff -r a94c3ccad618 -r fcd7d08a790e mail/src/main/java/com/sun/mail/auth/Ntlm.java
--- a/mail/src/main/java/com/sun/mail/auth/Ntlm.java Wed Jul 03 16:20:29 2013 -0700
+++ b/mail/src/main/java/com/sun/mail/auth/Ntlm.java Wed Jul 03 17:25:42 2013 -0700
@@ -1,7 +1,7 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 2005-2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005-2013 Oracle and/or its affiliates. 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
@@ -126,7 +126,7 @@
}
i = username.indexOf('\\');
if (i != -1) {
- ntdomain = username.substring(0, i).toUpperCase();
+ ntdomain = username.substring(0, i).toUpperCase(Locale.ENGLISH);
username = username.substring(i+1);
} else if (ntdomain == null) {
ntdomain = "";
diff -r a94c3ccad618 -r fcd7d08a790e mail/src/main/java/com/sun/mail/handlers/text_plain.java
--- a/mail/src/main/java/com/sun/mail/handlers/text_plain.java Wed Jul 03 16:20:29 2013 -0700
+++ b/mail/src/main/java/com/sun/mail/handlers/text_plain.java Wed Jul 03 17:25:42 2013 -0700
@@ -1,7 +1,7 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2010 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2013 Oracle and/or its affiliates. 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
@@ -139,7 +139,9 @@
} finally {
try {
is.close();
- } catch (IOException ex) { }
+ } catch (IOException ex) {
+ // ignore it
+ }
}
}
diff -r a94c3ccad618 -r fcd7d08a790e mail/src/main/java/com/sun/mail/handlers/text_xml.java
--- a/mail/src/main/java/com/sun/mail/handlers/text_xml.java Wed Jul 03 16:20:29 2013 -0700
+++ b/mail/src/main/java/com/sun/mail/handlers/text_xml.java Wed Jul 03 17:25:42 2013 -0700
@@ -1,7 +1,7 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2011 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2013 Oracle and/or its affiliates. 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
@@ -48,9 +48,11 @@
import javax.activation.DataContentHandler;
import javax.activation.DataSource;
import javax.mail.internet.ContentType;
+import javax.mail.internet.ParseException;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.TransformerException;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
@@ -137,10 +139,18 @@
} else {
transformer.transform((Source)obj, result);
}
- } catch (Exception ex) {
- throw new IOException(
+ } catch (TransformerException ex) {
+ IOException ioex = new IOException(
"Unable to run the JAXP transformer on a stream "
+ ex.getMessage());
+ ioex.initCause(ex);
+ throw ioex;
+ } catch (RuntimeException ex) {
+ IOException ioex = new IOException(
+ "Unable to run the JAXP transformer on a stream "
+ + ex.getMessage());
+ ioex.initCause(ex);
+ throw ioex;
}
}
@@ -150,7 +160,9 @@
return ct.getSubType().equals("xml") &&
(ct.getPrimaryType().equals("text") ||
ct.getPrimaryType().equals("application"));
- } catch (Exception ex) {
+ } catch (ParseException ex) {
+ return false;
+ } catch (RuntimeException ex) {
return false;
}
}
diff -r a94c3ccad618 -r fcd7d08a790e mail/src/main/java/com/sun/mail/iap/Argument.java
--- a/mail/src/main/java/com/sun/mail/iap/Argument.java Wed Jul 03 16:20:29 2013 -0700
+++ b/mail/src/main/java/com/sun/mail/iap/Argument.java Wed Jul 03 17:25:42 2013 -0700
@@ -140,7 +140,7 @@
* @param i number
*/
public Argument writeNumber(int i) {
- items.add(new Integer(i));
+ items.add(Integer.valueOf(i));
return this;
}
@@ -149,7 +149,7 @@
* @param i number
*/
public Argument writeNumber(long i) {
- items.add(new Long(i));
+ items.add(Long.valueOf(i));
return this;
}
diff -r a94c3ccad618 -r fcd7d08a790e mail/src/main/java/com/sun/mail/iap/ResponseInputStream.java
--- a/mail/src/main/java/com/sun/mail/iap/ResponseInputStream.java Wed Jul 03 16:20:29 2013 -0700
+++ b/mail/src/main/java/com/sun/mail/iap/ResponseInputStream.java Wed Jul 03 17:25:42 2013 -0700
@@ -1,7 +1,7 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2010 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2013 Oracle and/or its affiliates. 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
@@ -94,20 +94,18 @@
// Read a CRLF terminated line from the InputStream
while (!gotCRLF &&
((b = bin.read()) != -1)) {
- switch (b) {
- case '\n':
+ if (b == '\n') {
if ((idx > 0) && buffer[idx-1] == '\r')
gotCRLF = true;
- default:
- if (idx >= buffer.length) {
- int incr = buffer.length;
- if (incr > maxIncrement)
- incr = maxIncrement;
- ba.grow(incr);
- buffer = ba.getBytes();
- }
- buffer[idx++] = (byte)b;
}
+ if (idx >= buffer.length) {
+ int incr = buffer.length;
+ if (incr > maxIncrement)
+ incr = maxIncrement;
+ ba.grow(incr);
+ buffer = ba.getBytes();
+ }
+ buffer[idx++] = (byte)b;
}
if (b == -1)
diff -r a94c3ccad618 -r fcd7d08a790e mail/src/main/java/com/sun/mail/imap/IMAPFolder.java
--- a/mail/src/main/java/com/sun/mail/imap/IMAPFolder.java Wed Jul 03 16:20:29 2013 -0700
+++ b/mail/src/main/java/com/sun/mail/imap/IMAPFolder.java Wed Jul 03 17:25:42 2013 -0700
@@ -271,7 +271,7 @@
// the server
private long uidvalidity = -1; // UIDValidity
private long uidnext = -1; // UIDNext
- private long highestmodseq = -1; // HIGHESTMODSEQ: RFC 4551 - CONDSTORE
+ private volatile long highestmodseq = -1; // RFC 4551 - CONDSTORE
private boolean doExpungeNotification = true; // used in expunge handler
private Status cachedStatus = null;
@@ -1058,7 +1058,10 @@
if (ir.keyEquals("VANISHED")) {
// "VANISHED" SP ["(EARLIER)"] SP known-uids
String[] s = ir.readAtomStringList();
- // XXX - check that it really is "EARLIER"?
+ // check that it really is "EARLIER"
+ if (s == null || s.length != 1 ||
+ !s[0].equalsIgnoreCase("EARLIER"))
+ continue; // it's not, what to do with it here?
String uids = ir.readAtom();
UIDSet[] uidset = UIDSet.parseUIDSets(uids);
long[] luid = UIDSet.toArray(uidset, uidnext);
@@ -1400,7 +1403,7 @@
protocol.unselect();
else {
if (protocol != null) {
- MailboxInfo mi = protocol.examine(fullName);
+ protocol.examine(fullName);
if (protocol != null) // XXX - unnecessary?
protocol.close();
}
@@ -2407,6 +2410,8 @@
checkOpened(); // insure that folder is open
+ if (!(message instanceof IMAPMessage))
+ throw new MessagingException("message is not an IMAPMessage");
IMAPMessage m = (IMAPMessage)message;
// If the message already knows its UID, great ..
long uid;
diff -r a94c3ccad618 -r fcd7d08a790e mail/src/main/java/com/sun/mail/imap/IMAPMessage.java
--- a/mail/src/main/java/com/sun/mail/imap/IMAPMessage.java Wed Jul 03 16:20:29 2013 -0700
+++ b/mail/src/main/java/com/sun/mail/imap/IMAPMessage.java Wed Jul 03 17:25:42 2013 -0700
@@ -1119,7 +1119,7 @@
// add entry into uid table
if (((IMAPFolder)folder).uidTable == null)
((IMAPFolder)folder).uidTable = new Hashtable();
- ((IMAPFolder)folder).uidTable.put(new Long(u.uid), this);
+ ((IMAPFolder)folder).uidTable.put(Long.valueOf(u.uid), this);
}
// Check for header items
diff -r a94c3ccad618 -r fcd7d08a790e mail/src/main/java/com/sun/mail/imap/IMAPStore.java
--- a/mail/src/main/java/com/sun/mail/imap/IMAPStore.java Wed Jul 03 16:20:29 2013 -0700
+++ b/mail/src/main/java/com/sun/mail/imap/IMAPStore.java Wed Jul 03 17:25:42 2013 -0700
@@ -43,6 +43,7 @@
import java.lang.reflect.*;
import java.util.Vector;
import java.util.StringTokenizer;
+import java.util.Locale;
import java.io.PrintStream;
import java.io.IOException;
import java.net.InetAddress;
@@ -420,7 +421,7 @@
debugpassword = PropUtil.getBooleanSessionProperty(session,
"mail.debug.auth.password", false);
logger = new MailLogger(this.getClass(),
- "DEBUG " + name.toUpperCase(), session);
+ "DEBUG " + name.toUpperCase(Locale.ENGLISH), session);
boolean partialFetch = PropUtil.getBooleanSessionProperty(session,
"mail." + name + ".partialfetch", true);
@@ -788,7 +789,7 @@
* @return true if using SSL
* @since JavaMail 1.4.6
*/
- public boolean isSSL() {
+ public synchronized boolean isSSL() {
return usingSSL;
}
@@ -1565,7 +1566,9 @@
// to set the state and send the closed connection event
try {
super.close();
- } catch (MessagingException mex) { }
+ } catch (MessagingException mex) {
+ // ignore it
+ }
logger.fine("IMAPStore cleanup done");
}
@@ -1606,7 +1609,7 @@
if (folderConstructor != null) {
try {
Object[] o =
- { fullName, new Character(separator), this, isNamespace };
+ { fullName, Character.valueOf(separator), this, isNamespace };
f = (IMAPFolder)folderConstructor.newInstance(o);
} catch (Exception ex) {
logger.log(Level.FINE,
diff -r a94c3ccad618 -r fcd7d08a790e mail/src/main/java/com/sun/mail/imap/protocol/ENVELOPE.java
--- a/mail/src/main/java/com/sun/mail/imap/protocol/ENVELOPE.java Wed Jul 03 16:20:29 2013 -0700
+++ b/mail/src/main/java/com/sun/mail/imap/protocol/ENVELOPE.java Wed Jul 03 17:25:42 2013 -0700
@@ -1,7 +1,7 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2013 Oracle and/or its affiliates. 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
@@ -89,10 +89,11 @@
if (s != null) {
try {
date = mailDateFormat.parse(s);
- } catch (Exception pex) {
+ } catch (ParseException pex) {
+ } catch (RuntimeException pex) {
// We need to be *very* tolerant about bogus dates (and
- // there's lot of 'em around), so we ignore any
- // exception (including RunTimeExceptions) and just let
+ // there's lots of 'em around), so we ignore any
+ // exception (including RuntimeExceptions) and just let
// date be null.
}
}
diff -r a94c3ccad618 -r fcd7d08a790e mail/src/main/java/com/sun/mail/imap/protocol/IMAPProtocol.java
--- a/mail/src/main/java/com/sun/mail/imap/protocol/IMAPProtocol.java Wed Jul 03 16:20:29 2013 -0700
+++ b/mail/src/main/java/com/sun/mail/imap/protocol/IMAPProtocol.java Wed Jul 03 17:25:42 2013 -0700
@@ -253,6 +253,7 @@
return;
}
// only other choice is PREAUTH
+ assert r instanceof IMAPResponse;
IMAPResponse ir = (IMAPResponse)r;
if (ir.keyEquals("PREAUTH")) {
authenticated = true;
@@ -1948,7 +1949,7 @@
// There *will* be one SEARCH response.
if (ir.keyEquals("SEARCH")) {
while ((num = ir.readNumber()) != -1)
- v.addElement(new Integer(num));
+ v.addElement(Integer.valueOf(num));
r[i] = null;
}
}
@@ -2036,7 +2037,7 @@
IMAPResponse ir = (IMAPResponse)r[i];
if (ir.keyEquals("SORT")) {
while ((num = ir.readNumber()) != -1)
- v.addElement(new Integer(num));
+ v.addElement(Integer.valueOf(num));
r[i] = null;
}
}
@@ -2137,7 +2138,14 @@
Quota quota = parseQuota(ir);
Quota q = (Quota)tab.get(quota.quotaRoot);
if (q != null && q.resources != null) {
- // XXX - should merge resources
+ // merge resources
+ int newl = q.resources.length + quota.resources.length;
+ Quota.Resource[] newr = new Quota.Resource[newl];
+ System.arraycopy(q.resources, 0, newr, 0,
+ q.resources.length);
+ System.arraycopy(quota.resources, 0,
+ newr, q.resources.length, quota.resources.length);
+ quota.resources = newr;
}
tab.put(quota.quotaRoot, quota);
r[i] = null;
diff -r a94c3ccad618 -r fcd7d08a790e mail/src/main/java/com/sun/mail/imap/protocol/SearchSequence.java
--- a/mail/src/main/java/com/sun/mail/imap/protocol/SearchSequence.java Wed Jul 03 16:20:29 2013 -0700
+++ b/mail/src/main/java/com/sun/mail/imap/protocol/SearchSequence.java Wed Jul 03 17:25:42 2013 -0700
@@ -125,17 +125,11 @@
* non US-ASCII characters.
*/
public static boolean isAscii(SearchTerm term) {
- if (term instanceof AndTerm || term instanceof OrTerm) {
- SearchTerm[] terms;
- if (term instanceof AndTerm)
- terms = ((AndTerm)term).getTerms();
- else
- terms = ((OrTerm)term).getTerms();
-
- for (int i = 0; i < terms.length; i++)
- if (!isAscii(terms[i])) // outta here !
- return false;
- } else if (term instanceof NotTerm)
+ if (term instanceof AndTerm)
+ return isAscii(((AndTerm)term).getTerms());
+ else if (term instanceof OrTerm)
+ return isAscii(((OrTerm)term).getTerms());
+ else if (term instanceof NotTerm)
return isAscii(((NotTerm)term).getTerm());
else if (term instanceof StringTerm)
return isAscii(((StringTerm)term).getPattern());
@@ -147,6 +141,17 @@
}
/**
+ * Check if any of the "text" terms in the given SearchTerms contain
+ * non US-ASCII characters.
+ */
+ public static boolean isAscii(SearchTerm[] terms) {
+ for (int i = 0; i < terms.length; i++)
+ if (!isAscii(terms[i])) // outta here !
+ return false;
+ return true;
+ }
+
+ /**
* Does this string contain only ASCII characters?
*/
public static boolean isAscii(String s) {
diff -r a94c3ccad618 -r fcd7d08a790e mail/src/main/java/com/sun/mail/pop3/POP3Folder.java
--- a/mail/src/main/java/com/sun/mail/pop3/POP3Folder.java Wed Jul 03 16:20:29 2013 -0700
+++ b/mail/src/main/java/com/sun/mail/pop3/POP3Folder.java Wed Jul 03 17:25:42 2013 -0700
@@ -1,7 +1,7 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2013 Oracle and/or its affiliates. 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
@@ -356,7 +356,7 @@
Constructor cons = store.messageConstructor;
if (cons != null) {
try {
- Object[] o = { this, new Integer(msgno) };
+ Object[] o = { this, Integer.valueOf(msgno) };
m = (POP3Message)cons.newInstance(o);
} catch (Exception ex) {
// ignore
@@ -454,6 +454,8 @@
*/
public synchronized String getUID(Message msg) throws MessagingException {
checkOpen();
+ if (!(msg instanceof POP3Message))
+ throw new MessagingException("message is not a POP3Message");
POP3Message m = (POP3Message)msg;
try {
if (!store.supportsUidl)
@@ -506,7 +508,7 @@
int size = Integer.parseInt(st.nextToken());
if (msgnum > 0 && msgnum <= total)
sizes[msgnum - 1] = size;
- } catch (Exception e) {
+ } catch (RuntimeException e) {
}
}
} catch (IOException ex) {
diff -r a94c3ccad618 -r fcd7d08a790e mail/src/main/java/com/sun/mail/pop3/POP3Message.java
--- a/mail/src/main/java/com/sun/mail/pop3/POP3Message.java Wed Jul 03 16:20:29 2013 -0700
+++ b/mail/src/main/java/com/sun/mail/pop3/POP3Message.java Wed Jul 03 17:25:42 2013 -0700
@@ -1,7 +1,7 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2013 Oracle and/or its affiliates. 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
@@ -77,6 +77,7 @@
public POP3Message(Folder folder, int msgno)
throws MessagingException {
super(folder, msgno);
+ assert folder instanceof POP3Folder;
this.folder = (POP3Folder)folder;
}
@@ -159,7 +160,6 @@
if (rawcontent == null) {
TempFile cache = folder.getFileCache();
if (cache != null) {
- Session s = ((POP3Store)(folder.getStore())).getSession();
if (folder.logger.isLoggable(Level.FINE))
folder.logger.fine("caching message #" + msgnum +
" in temp file");
@@ -565,7 +565,6 @@
InputStream rawcontent = (InputStream)rawData.get();
if (rawcontent == null && ignoreList == null &&
!((POP3Store)(folder.getStore())).cacheWriteTo) {
- Session s = ((POP3Store)(folder.getStore())).getSession();
if (folder.logger.isLoggable(Level.FINE))
folder.logger.fine("streaming msg " + msgnum);
if (!folder.getProtocol().retr(msgnum, os)) {
diff -r a94c3ccad618 -r fcd7d08a790e mail/src/main/java/com/sun/mail/pop3/POP3Store.java
--- a/mail/src/main/java/com/sun/mail/pop3/POP3Store.java Wed Jul 03 16:20:29 2013 -0700
+++ b/mail/src/main/java/com/sun/mail/pop3/POP3Store.java Wed Jul 03 17:25:42 2013 -0700
@@ -402,7 +402,7 @@
* @return true if using SSL
* @since JavaMail 1.4.6
*/
- public boolean isSSL() {
+ public synchronized boolean isSSL() {
return usingSSL;
}
diff -r a94c3ccad618 -r fcd7d08a790e mail/src/main/java/com/sun/mail/pop3/Protocol.java
--- a/mail/src/main/java/com/sun/mail/pop3/Protocol.java Wed Jul 03 16:20:29 2013 -0700
+++ b/mail/src/main/java/com/sun/mail/pop3/Protocol.java Wed Jul 03 17:25:42 2013 -0700
@@ -1,7 +1,7 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2013 Oracle and/or its affiliates. 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
@@ -264,7 +264,7 @@
r = readResponse();
if (!r.ok) {
String err = r.data != null ? r.data : "USER command failed";
- r = readResponse();
+ readResponse(); // read and ignore PASS response
batchCommandEnd();
return err;
}
@@ -378,7 +378,7 @@
StringTokenizer st = new StringTokenizer(r.data);
s.total = Integer.parseInt(st.nextToken());
s.size = Integer.parseInt(st.nextToken());
- } catch (Exception e) {
+ } catch (RuntimeException e) {
}
}
return s;
@@ -395,7 +395,8 @@
StringTokenizer st = new StringTokenizer(r.data);
st.nextToken(); // skip message number
size = Integer.parseInt(st.nextToken());
- } catch (Exception e) {
+ } catch (RuntimeException e) {
+ // ignore it
}
}
return size;
@@ -441,7 +442,7 @@
logger.fine("pipeline message size " + size);
size += SLOP;
}
- } catch (Exception e) {
+ } catch (RuntimeException e) {
}
}
r = readResponse();
@@ -481,7 +482,7 @@
size += SLOP;
}
}
- } catch (Exception e) {
+ } catch (RuntimeException e) {
}
}
r.bytes = readMultilineResponse(size);
@@ -612,7 +613,9 @@
}
try {
r.bytes.close();
- } catch (IOException ex) { }
+ } catch (IOException ex) {
+ // ignore it
+ }
return true;
}
diff -r a94c3ccad618 -r fcd7d08a790e mail/src/main/java/com/sun/mail/smtp/DigestMD5.java
--- a/mail/src/main/java/com/sun/mail/smtp/DigestMD5.java Wed Jul 03 16:20:29 2013 -0700
+++ b/mail/src/main/java/com/sun/mail/smtp/DigestMD5.java Wed Jul 03 17:25:42 2013 -0700
@@ -1,7 +1,7 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2013 Oracle and/or its affiliates. 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
@@ -203,6 +203,8 @@
}
key = null;
break;
+ default: // XXX - should never happen?
+ break;
}
}
return map;
diff -r a94c3ccad618 -r fcd7d08a790e mail/src/main/java/com/sun/mail/smtp/SMTPTransport.java
--- a/mail/src/main/java/com/sun/mail/smtp/SMTPTransport.java Wed Jul 03 16:20:29 2013 -0700
+++ b/mail/src/main/java/com/sun/mail/smtp/SMTPTransport.java Wed Jul 03 17:25:42 2013 -0700
@@ -511,7 +511,7 @@
* @return true if using SSL
* @since JavaMail 1.4.6
*/
- public boolean isSSL() {
+ public synchronized boolean isSSL() {
return serverSocket instanceof SSLSocket;
}
@@ -696,7 +696,9 @@
if (!connected) {
try {
closeConnection();
- } catch (MessagingException mex) { } // ignore it
+ } catch (MessagingException mex) {
+ // ignore it
+ }
}
}
}
@@ -916,10 +918,7 @@
void doAuth(String host, String authzid, String user, String passwd)
throws MessagingException, IOException {
DigestMD5 md5 = getMD5();
- if (md5 == null) {
- resp = -1;
- return; // XXX - should never happen
- }
+ assert md5 != null;
byte[] b = md5.authClient(host, user, passwd, getSASLRealm(),
getLastServerResponse());
@@ -962,6 +961,7 @@
void doAuth(String host, String authzid, String user, String passwd)
throws MessagingException, IOException {
+ assert ntlm != null;
String type3 = ntlm.generateType3Msg(
getLastServerResponse().substring(4).trim());
@@ -1276,13 +1276,17 @@
} else {
try {
closeConnection();
- } catch (MessagingException mex) { } // ignore it
+ } catch (MessagingException mex) {
+ // ignore it
+ }
return false;
}
} catch (Exception ex) {
try {
closeConnection();
- } catch (MessagingException mex) { } // ignore it
+ } catch (MessagingException mex) {
+ // ignore it
+ }
return false;
}
}
@@ -1444,7 +1448,9 @@
super.finalize();
try {
closeConnection();
- } catch (MessagingException mex) { } // ignore it
+ } catch (MessagingException mex) {
+ // ignore it
+ }
}
///////////////////// smtp stuff ///////////////////////
@@ -1620,6 +1626,8 @@
// oh well...
}
break;
+ default:
+ break;
}
throw ex;
}
diff -r a94c3ccad618 -r fcd7d08a790e mail/src/main/java/com/sun/mail/util/SocketConnectException.java
--- a/mail/src/main/java/com/sun/mail/util/SocketConnectException.java Wed Jul 03 16:20:29 2013 -0700
+++ b/mail/src/main/java/com/sun/mail/util/SocketConnectException.java Wed Jul 03 17:25:42 2013 -0700
@@ -84,8 +84,9 @@
*/
public Exception getException() {
// the "cause" is always an Exception; see constructor above
- assert getCause() instanceof Exception;
- return (Exception)getCause();
+ Throwable t = getCause();
+ assert t instanceof Exception;
+ return (Exception)t;
}
/**
diff -r a94c3ccad618 -r fcd7d08a790e mail/src/main/java/com/sun/mail/util/SocketFetcher.java
--- a/mail/src/main/java/com/sun/mail/util/SocketFetcher.java Wed Jul 03 16:20:29 2013 -0700
+++ b/mail/src/main/java/com/sun/mail/util/SocketFetcher.java Wed Jul 03 17:25:42 2013 -0700
@@ -608,7 +608,7 @@
Method getInstance = hnc.getMethod("getInstance",
new Class[] { byte.class });
Object hostnameChecker = getInstance.invoke(new Object(),
- new Object[] { new Byte((byte)2) });
+ new Object[] { Byte.valueOf((byte)2) });
// invoke hostnameChecker.match( server, cert)
if (logger.isLoggable(Level.FINER))
diff -r a94c3ccad618 -r fcd7d08a790e mail/src/main/java/javax/mail/Message.java
--- a/mail/src/main/java/javax/mail/Message.java Wed Jul 03 16:20:29 2013 -0700
+++ b/mail/src/main/java/javax/mail/Message.java Wed Jul 03 17:25:42 2013 -0700
@@ -335,7 +335,7 @@
}
if (bcc != null) {
System.arraycopy(bcc, 0, addresses, pos, bcc.length);
- pos += bcc.length;
+ // pos += bcc.length;
}
return addresses;
}
diff -r a94c3ccad618 -r fcd7d08a790e mail/src/main/java/javax/mail/Session.java
--- a/mail/src/main/java/javax/mail/Session.java Wed Jul 03 16:20:29 2013 -0700
+++ b/mail/src/main/java/javax/mail/Session.java Wed Jul 03 17:25:42 2013 -0700
@@ -217,7 +217,7 @@
loadAddressMap(cl);
}
- private final void initLogger() {
+ private final synchronized void initLogger() {
logger = new MailLogger(this.getClass(), "DEBUG", debug, getDebugOut());
}
diff -r a94c3ccad618 -r fcd7d08a790e mail/src/main/java/javax/mail/internet/HeaderTokenizer.java
--- a/mail/src/main/java/javax/mail/internet/HeaderTokenizer.java Wed Jul 03 16:20:29 2013 -0700
+++ b/mail/src/main/java/javax/mail/internet/HeaderTokenizer.java Wed Jul 03 17:25:42 2013 -0700
@@ -270,6 +270,8 @@
* already at end of header
*/
public String getRemainder() {
+ if (nextPos >= string.length())
+ return null;
return string.substring(nextPos);
}
diff -r a94c3ccad618 -r fcd7d08a790e mail/src/main/java/javax/mail/internet/InternetHeaders.java
--- a/mail/src/main/java/javax/mail/internet/InternetHeaders.java Wed Jul 03 16:20:29 2013 -0700
+++ b/mail/src/main/java/javax/mail/internet/InternetHeaders.java Wed Jul 03 17:25:42 2013 -0700
@@ -1,7 +1,7 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2010 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2013 Oracle and/or its affiliates. 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
@@ -160,7 +160,7 @@
* InternetHeaders object. Can return
* either a String or a Header object.
*/
- static class matchEnum implements Enumeration {
+ static class MatchEnum implements Enumeration {
private Iterator e; // enum object of headers List
// XXX - is this overkill? should we step through in index
// order instead?
@@ -175,7 +175,7 @@
* matching or non-matching headers, and whether to return
* header lines or Header objects.
*/
- matchEnum(List v, String n[], boolean m, boolean l) {
+ MatchEnum(List v, String n[], boolean m, boolean l) {
e = v.iterator();
names = n;
match = m;
@@ -538,7 +538,7 @@
* @return Header objects
*/
public Enumeration getAllHeaders() {
- return (new matchEnum(headers, null, false, false));
+ return (new MatchEnum(headers, null, false, false));
}
/**
@@ -547,7 +547,7 @@
* @return matching Header objects
*/
public Enumeration getMatchingHeaders(String[] names) {
- return (new matchEnum(headers, names, true, false));
+ return (new MatchEnum(headers, names, true, false));
}
/**
@@ -556,7 +556,7 @@
* @return non-matching Header objects
*/
public Enumeration getNonMatchingHeaders(String[] names) {
- return (new matchEnum(headers, names, false, false));
+ return (new MatchEnum(headers, names, false, false));
}
/**
@@ -597,13 +597,13 @@
* Return all matching header lines as an Enumeration of Strings.
*/
public Enumeration getMatchingHeaderLines(String[] names) {
- return (new matchEnum(headers, names, true, true));
+ return (new MatchEnum(headers, names, true, true));
}
/**
* Return all non-matching header lines
*/
public Enumeration getNonMatchingHeaderLines(String[] names) {
- return (new matchEnum(headers, names, false, true));
+ return (new MatchEnum(headers, names, false, true));
}
}
diff -r a94c3ccad618 -r fcd7d08a790e mail/src/main/java/javax/mail/internet/ParameterList.java
--- a/mail/src/main/java/javax/mail/internet/ParameterList.java Wed Jul 03 16:20:29 2013 -0700
+++ b/mail/src/main/java/javax/mail/internet/ParameterList.java Wed Jul 03 17:25:42 2013 -0700
@@ -400,7 +400,6 @@
Iterator it = multisegmentNames.iterator();
while (it.hasNext()) {
String name = (String)it.next();
- StringBuffer sb = new StringBuffer();
MultiValue mv = new MultiValue();
/*
* Now find all the segments for this name and
@@ -746,7 +745,7 @@
"Missing language in encoded value: " + value);
return v; // not encoded correctly? return as is.
}
- String lang = value.substring(i + 1, li);
+ // String lang = value.substring(i + 1, li);
v.value = value.substring(li + 1);
v.charset = charset;
} catch (NumberFormatException nex) {
diff -r a94c3ccad618 -r fcd7d08a790e mail/src/main/java/javax/mail/search/BodyTerm.java
--- a/mail/src/main/java/javax/mail/search/BodyTerm.java Wed Jul 03 16:20:29 2013 -0700
+++ b/mail/src/main/java/javax/m
[truncated due to length]