commits@javamail.java.net

[javamail~mercurial:749] mail.mime.encodefilename property should override RFC 2231 encoding - bug

From: <shannon_at_java.net>
Date: Tue, 11 Aug 2015 21:54:45 +0000

Project: javamail
Repository: mercurial
Revision: 749
Author: shannon
Date: 2015-08-11 18:54:28 UTC
Link:

Log Message:
------------
Update version to 1.5.5-SNAPSHOT.
Add a profile to allow building mbox on JDK 1.8.
add support for setting GMail labels on messages - bug 6886
try to make test more reliable by reducing dependency on Thread.sleep
remove unused latch
watch method should fail if IdleManager is shut down
fix finalize methods to use try/finally
If an SSLSocketFactory was configured via properties, be sure to use it
even if SSL wasn't requested.
Add new implementation of MailDateFormat as NewMailDateFormat
Add unit tests for (New)MailDateFormat
Replace MailDateFormat with NewMailDateFormat
Fix some javadoc errors and warnings.
Contribution from anthony.vanelverdinghe_at_gmail.com updates MailDateFormat.
Fix timing-dependent tests for slower machines.

(From Anthony)
fix typos in sendMessage javadocs - bug 6938
mail.mime.encodefilename property should override RFC 2231 encoding - bug 6943


Revisions:
----------
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749


Modified Paths:
---------------
client/pom.xml
demo/pom.xml
dsn/pom.xml
gimap/pom.xml
imap/pom.xml
javadoc/pom.xml
logging/pom.xml
mail/pom.xml
mailapi/pom.xml
mailapijar/pom.xml
mailhandler/pom.xml
mbox/native/pom.xml
mbox/pom.xml
oldmail/pom.xml
outlook/pom.xml
parent-distrib/pom.xml
pom.xml
pop3/pom.xml
publish/pom.xml
servlet/pom.xml
smtp/pom.xml
taglib/pom.xml
webapp/pom.xml
doc/release/CHANGES.txt
gimap/src/main/java/com/sun/mail/gimap/GmailFolder.java
gimap/src/main/java/com/sun/mail/gimap/GmailMessage.java
gimap/src/main/java/com/sun/mail/gimap/protocol/GmailProtocol.java
mail/src/main/java/com/sun/mail/imap/IMAPFolder.java
mail/src/main/java/com/sun/mail/imap/IMAPMessage.java
mail/src/main/java/com/sun/mail/imap/protocol/FetchResponse.java
mail/src/test/java/com/sun/mail/smtp/SMTPIOExceptionTest.java
mail/src/test/java/com/sun/mail/imap/IMAPIdleManagerTest.java
mail/src/main/java/com/sun/mail/imap/IdleManager.java
mail/src/main/java/com/sun/mail/iap/Protocol.java
mail/src/main/java/com/sun/mail/imap/IMAPStore.java
mail/src/main/java/com/sun/mail/pop3/POP3Folder.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/pop3/TempFile.java
mail/src/main/java/com/sun/mail/smtp/SMTPTransport.java
mail/src/main/java/javax/mail/Folder.java
mail/src/main/java/javax/mail/Service.java
mail/src/main/java/javax/mail/util/SharedFileInputStream.java
mbox/src/main/java/com/sun/mail/mbox/TempFile.java
mail/src/main/java/com/sun/mail/util/SocketFetcher.java
mail/src/main/java/com/sun/mail/imap/protocol/ENVELOPE.java
mail/src/main/java/com/sun/mail/imap/protocol/INTERNALDATE.java
mail/src/main/java/javax/mail/internet/MailDateFormat.java
mail/src/test/java/javax/mail/internet/MailDateFormatTest.java
gimap/src/main/java/com/sun/mail/gimap/GmailMsgIdTerm.java
gimap/src/main/java/com/sun/mail/gimap/GmailThrIdTerm.java
mail/src/main/java/javax/mail/internet/InternetAddress.java
mail/src/main/java/javax/mail/internet/ParameterList.java
mail/src/main/java/javax/mail/internet/MimeBodyPart.java


Added Paths:
------------
mail/src/main/java/javax/mail/internet/NewMailDateFormat.java
mail/src/test/java/javax/mail/internet/MailDateFormatTest.java
mail/src/test/resources/javax/mail/internet/MailDateFormat_new.ser
mail/src/test/resources/javax/mail/internet/MailDateFormat_old.ser
mail/src/test/java/javax/mail/internet/EncodeFileName.java
mail/src/test/java/javax/mail/internet/EncodeFileNameNoEncodeParameters.java
mail/src/test/java/javax/mail/internet/MimeBodyPartTestSuite.java
mail/src/test/java/javax/mail/internet/NoEncodeFileName.java


Diffs:
------
diff -r 4231ed67e7aa -r 41cba1f4097b client/pom.xml
--- a/client/pom.xml Mon Jun 22 13:56:06 2015 -0700
+++ b/client/pom.xml Wed Jun 24 11:36:49 2015 -0700
@@ -48,7 +48,7 @@
     <parent>
         <groupId>com.sun.mail</groupId>
         <artifactId>all</artifactId>
- <version>1.5.4</version>
+ <version>1.5.5-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
     <groupId>com.sun.mail</groupId>

diff -r 4231ed67e7aa -r 41cba1f4097b demo/pom.xml
--- a/demo/pom.xml Mon Jun 22 13:56:06 2015 -0700
+++ b/demo/pom.xml Wed Jun 24 11:36:49 2015 -0700
@@ -48,7 +48,7 @@
     <parent>
         <groupId>com.sun.mail</groupId>
         <artifactId>all</artifactId>
- <version>1.5.4</version>
+ <version>1.5.5-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
     <groupId>com.sun.mail</groupId>

diff -r 4231ed67e7aa -r 41cba1f4097b dsn/pom.xml
--- a/dsn/pom.xml Mon Jun 22 13:56:06 2015 -0700
+++ b/dsn/pom.xml Wed Jun 24 11:36:49 2015 -0700
@@ -48,7 +48,7 @@
     <parent>
         <groupId>com.sun.mail</groupId>
         <artifactId>all</artifactId>
- <version>1.5.4</version>
+ <version>1.5.5-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
     <groupId>com.sun.mail</groupId>

diff -r 4231ed67e7aa -r 41cba1f4097b gimap/pom.xml
--- a/gimap/pom.xml Mon Jun 22 13:56:06 2015 -0700
+++ b/gimap/pom.xml Wed Jun 24 11:36:49 2015 -0700
@@ -48,7 +48,7 @@
     <parent>
         <groupId>com.sun.mail</groupId>
         <artifactId>all</artifactId>
- <version>1.5.4</version>
+ <version>1.5.5-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
     <groupId>com.sun.mail</groupId>

diff -r 4231ed67e7aa -r 41cba1f4097b imap/pom.xml
--- a/imap/pom.xml Mon Jun 22 13:56:06 2015 -0700
+++ b/imap/pom.xml Wed Jun 24 11:36:49 2015 -0700
@@ -48,7 +48,7 @@
     <parent>
         <groupId>com.sun.mail</groupId>
         <artifactId>parent-distrib</artifactId>
- <version>1.5.4</version>
+ <version>1.5.5-SNAPSHOT</version>
         <relativePath>../parent-distrib/pom.xml</relativePath>
     </parent>
     <modelVersion>4.0.0</modelVersion>

diff -r 4231ed67e7aa -r 41cba1f4097b javadoc/pom.xml
--- a/javadoc/pom.xml Mon Jun 22 13:56:06 2015 -0700
+++ b/javadoc/pom.xml Wed Jun 24 11:36:49 2015 -0700
@@ -48,13 +48,13 @@
     <parent>
         <groupId>com.sun.mail</groupId>
         <artifactId>all</artifactId>
- <version>1.5.4</version>
+ <version>1.5.5-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
     <groupId>com.sun.mail</groupId>
     <artifactId>javadoc</artifactId>
     <packaging>pom</packaging>
- <version>1.5.4</version>
+ <version>1.5.5-SNAPSHOT</version>
     <name>JavaMail API javadocs</name>
     <description>${project.name}</description>
 

diff -r 4231ed67e7aa -r 41cba1f4097b logging/pom.xml
--- a/logging/pom.xml Mon Jun 22 13:56:06 2015 -0700
+++ b/logging/pom.xml Wed Jun 24 11:36:49 2015 -0700
@@ -48,7 +48,7 @@
     <parent>
         <groupId>com.sun.mail</groupId>
         <artifactId>all</artifactId>
- <version>1.5.4</version>
+ <version>1.5.5-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
     <groupId>com.sun.mail</groupId>

diff -r 4231ed67e7aa -r 41cba1f4097b mail/pom.xml
--- a/mail/pom.xml Mon Jun 22 13:56:06 2015 -0700
+++ b/mail/pom.xml Wed Jun 24 11:36:49 2015 -0700
@@ -48,7 +48,7 @@
     <parent>
         <groupId>com.sun.mail</groupId>
         <artifactId>all</artifactId>
- <version>1.5.4</version>
+ <version>1.5.5-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
     <groupId>com.sun.mail</groupId>

diff -r 4231ed67e7aa -r 41cba1f4097b mailapi/pom.xml
--- a/mailapi/pom.xml Mon Jun 22 13:56:06 2015 -0700
+++ b/mailapi/pom.xml Wed Jun 24 11:36:49 2015 -0700
@@ -56,7 +56,7 @@
     <parent>
         <groupId>com.sun.mail</groupId>
         <artifactId>all</artifactId>
- <version>1.5.4</version>
+ <version>1.5.5-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
     <groupId>com.sun.mail</groupId>

diff -r 4231ed67e7aa -r 41cba1f4097b mailapijar/pom.xml
--- a/mailapijar/pom.xml Mon Jun 22 13:56:06 2015 -0700
+++ b/mailapijar/pom.xml Wed Jun 24 11:36:49 2015 -0700
@@ -55,7 +55,7 @@
     <parent>
         <groupId>com.sun.mail</groupId>
         <artifactId>all</artifactId>
- <version>1.5.4</version>
+ <version>1.5.5-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
     <groupId>javax.mail</groupId>

diff -r 4231ed67e7aa -r 41cba1f4097b mailhandler/pom.xml
--- a/mailhandler/pom.xml Mon Jun 22 13:56:06 2015 -0700
+++ b/mailhandler/pom.xml Wed Jun 24 11:36:49 2015 -0700
@@ -48,7 +48,7 @@
     <parent>
         <groupId>com.sun.mail</groupId>
         <artifactId>parent-distrib</artifactId>
- <version>1.5.4</version>
+ <version>1.5.5-SNAPSHOT</version>
         <relativePath>../parent-distrib/pom.xml</relativePath>
     </parent>
     <modelVersion>4.0.0</modelVersion>

diff -r 4231ed67e7aa -r 41cba1f4097b mbox/native/pom.xml
--- a/mbox/native/pom.xml Mon Jun 22 13:56:06 2015 -0700
+++ b/mbox/native/pom.xml Wed Jun 24 11:36:49 2015 -0700
@@ -48,7 +48,7 @@
     <parent>
         <groupId>com.sun.mail</groupId>
         <artifactId>all</artifactId>
- <version>1.5.4</version>
+ <version>1.5.5-SNAPSHOT</version>
         <relativePath>../../pom.xml</relativePath>
     </parent>
     <modelVersion>4.0.0</modelVersion>

diff -r 4231ed67e7aa -r 41cba1f4097b mbox/pom.xml
--- a/mbox/pom.xml Mon Jun 22 13:56:06 2015 -0700
+++ b/mbox/pom.xml Wed Jun 24 11:36:49 2015 -0700
@@ -48,7 +48,7 @@
     <parent>
         <groupId>com.sun.mail</groupId>
         <artifactId>all</artifactId>
- <version>1.5.4</version>
+ <version>1.5.5-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
     <groupId>com.sun.mail</groupId>

diff -r 4231ed67e7aa -r 41cba1f4097b oldmail/pom.xml
--- a/oldmail/pom.xml Mon Jun 22 13:56:06 2015 -0700
+++ b/oldmail/pom.xml Wed Jun 24 11:36:49 2015 -0700
@@ -53,7 +53,7 @@
     <parent>
         <groupId>com.sun.mail</groupId>
         <artifactId>all</artifactId>
- <version>1.5.4</version>
+ <version>1.5.5-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
     <groupId>javax.mail</groupId>

diff -r 4231ed67e7aa -r 41cba1f4097b outlook/pom.xml
--- a/outlook/pom.xml Mon Jun 22 13:56:06 2015 -0700
+++ b/outlook/pom.xml Wed Jun 24 11:36:49 2015 -0700
@@ -48,7 +48,7 @@
     <parent>
         <groupId>com.sun.mail</groupId>
         <artifactId>all</artifactId>
- <version>1.5.4</version>
+ <version>1.5.5-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
     <groupId>com.sun.mail</groupId>

diff -r 4231ed67e7aa -r 41cba1f4097b parent-distrib/pom.xml
--- a/parent-distrib/pom.xml Mon Jun 22 13:56:06 2015 -0700
+++ b/parent-distrib/pom.xml Wed Jun 24 11:36:49 2015 -0700
@@ -48,7 +48,7 @@
     <parent>
         <groupId>com.sun.mail</groupId>
         <artifactId>all</artifactId>
- <version>1.5.4</version>
+ <version>1.5.5-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
     <groupId>com.sun.mail</groupId>

diff -r 4231ed67e7aa -r 41cba1f4097b pom.xml
--- a/pom.xml Mon Jun 22 13:56:06 2015 -0700
+++ b/pom.xml Wed Jun 24 11:36:49 2015 -0700
@@ -54,7 +54,7 @@
     <groupId>com.sun.mail</groupId>
     <artifactId>all</artifactId>
     <packaging>pom</packaging>
- <version>1.5.4</version>
+ <version>1.5.5-SNAPSHOT</version>
     <name>JavaMail API distribution</name>
     <description>${project.name}</description>
     <url>http://javamail.java.net</url>
@@ -85,9 +85,9 @@
     </organization>
 
     <properties>
- <mail.version>1.5.4</mail.version>
+ <mail.version>1.5.5-SNAPSHOT</mail.version>
         <!-- like mail.version, but with underscores instead of dots -->
- <mail.zipversion>1_5_4</mail.zipversion>
+ <mail.zipversion>1_5_5-SNAPSHOT</mail.zipversion>
         <mail.spec.version>1.5</mail.spec.version>
         <activation-api.version>1.1</activation-api.version>
         <!-- defaults that are overridden in mail module -->

diff -r 4231ed67e7aa -r 41cba1f4097b pop3/pom.xml
--- a/pop3/pom.xml Mon Jun 22 13:56:06 2015 -0700
+++ b/pop3/pom.xml Wed Jun 24 11:36:49 2015 -0700
@@ -48,7 +48,7 @@
     <parent>
         <groupId>com.sun.mail</groupId>
         <artifactId>parent-distrib</artifactId>
- <version>1.5.4</version>
+ <version>1.5.5-SNAPSHOT</version>
         <relativePath>../parent-distrib/pom.xml</relativePath>
     </parent>
     <modelVersion>4.0.0</modelVersion>

diff -r 4231ed67e7aa -r 41cba1f4097b publish/pom.xml
--- a/publish/pom.xml Mon Jun 22 13:56:06 2015 -0700
+++ b/publish/pom.xml Wed Jun 24 11:36:49 2015 -0700
@@ -48,13 +48,13 @@
     <parent>
         <groupId>com.sun.mail</groupId>
         <artifactId>all</artifactId>
- <version>1.5.4</version>
+ <version>1.5.5-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
     <groupId>com.sun.mail</groupId>
     <artifactId>publish</artifactId>
     <packaging>pom</packaging>
- <version>1.5.4</version>
+ <version>1.5.5-SNAPSHOT</version>
     <name>JavaMail API publish project</name>
 
     <build>
@@ -89,44 +89,44 @@
         <dependency>
             <groupId>com.sun.mail</groupId>
             <artifactId>javax.mail</artifactId>
- <version>1.5.4</version>
+ <version>1.5.5-SNAPSHOT</version>
         </dependency>
     <!--
         <dependency>
             <groupId>com.sun.mail</groupId>
             <artifactId>demo</artifactId>
- <version>1.5.4</version>
+ <version>1.5.5-SNAPSHOT</version>
         </dependency>
         <dependency>
             <groupId>com.sun.mail</groupId>
             <artifactId>client</artifactId>
- <version>1.5.4</version>
+ <version>1.5.5-SNAPSHOT</version>
         </dependency>
         <dependency>
             <groupId>com.sun.mail</groupId>
             <artifactId>servlet</artifactId>
- <version>1.5.4</version>
+ <version>1.5.5-SNAPSHOT</version>
         </dependency>
         <dependency>
             <groupId>com.sun.mail</groupId>
             <artifactId>webapp</artifactId>
             <type>war</type>
- <version>1.5.4</version>
+ <version>1.5.5-SNAPSHOT</version>
         </dependency>
         <dependency>
             <groupId>com.sun.mail</groupId>
             <artifactId>taglib</artifactId>
- <version>1.5.4</version>
+ <version>1.5.5-SNAPSHOT</version>
         </dependency>
         <dependency>
             <groupId>com.sun.mail</groupId>
             <artifactId>logging</artifactId>
- <version>1.5.4</version>
+ <version>1.5.5-SNAPSHOT</version>
         </dependency>
         <dependency>
             <groupId>com.sun.mail</groupId>
             <artifactId>outlook</artifactId>
- <version>1.5.4</version>
+ <version>1.5.5-SNAPSHOT</version>
         </dependency>
     -->
     </dependencies>

diff -r 4231ed67e7aa -r 41cba1f4097b servlet/pom.xml
--- a/servlet/pom.xml Mon Jun 22 13:56:06 2015 -0700
+++ b/servlet/pom.xml Wed Jun 24 11:36:49 2015 -0700
@@ -48,7 +48,7 @@
     <parent>
         <groupId>com.sun.mail</groupId>
         <artifactId>all</artifactId>
- <version>1.5.4</version>
+ <version>1.5.5-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
     <groupId>com.sun.mail</groupId>

diff -r 4231ed67e7aa -r 41cba1f4097b smtp/pom.xml
--- a/smtp/pom.xml Mon Jun 22 13:56:06 2015 -0700
+++ b/smtp/pom.xml Wed Jun 24 11:36:49 2015 -0700
@@ -48,7 +48,7 @@
     <parent>
         <groupId>com.sun.mail</groupId>
         <artifactId>parent-distrib</artifactId>
- <version>1.5.4</version>
+ <version>1.5.5-SNAPSHOT</version>
         <relativePath>../parent-distrib/pom.xml</relativePath>
     </parent>
     <modelVersion>4.0.0</modelVersion>

diff -r 4231ed67e7aa -r 41cba1f4097b taglib/pom.xml
--- a/taglib/pom.xml Mon Jun 22 13:56:06 2015 -0700
+++ b/taglib/pom.xml Wed Jun 24 11:36:49 2015 -0700
@@ -48,7 +48,7 @@
     <parent>
         <groupId>com.sun.mail</groupId>
         <artifactId>all</artifactId>
- <version>1.5.4</version>
+ <version>1.5.5-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
     <groupId>com.sun.mail</groupId>

diff -r 4231ed67e7aa -r 41cba1f4097b webapp/pom.xml
--- a/webapp/pom.xml Mon Jun 22 13:56:06 2015 -0700
+++ b/webapp/pom.xml Wed Jun 24 11:36:49 2015 -0700
@@ -48,7 +48,7 @@
     <parent>
         <groupId>com.sun.mail</groupId>
         <artifactId>all</artifactId>
- <version>1.5.4</version>
+ <version>1.5.5-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
     <groupId>com.sun.mail</groupId>


diff -r 41cba1f4097b -r ec8cf1942372 mbox/native/pom.xml
--- a/mbox/native/pom.xml Wed Jun 24 11:36:49 2015 -0700
+++ b/mbox/native/pom.xml Wed Jun 24 11:41:59 2015 -0700
@@ -3,7 +3,7 @@
 
     DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
 
- Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
+ Copyright (c) 1997-2015 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
@@ -60,24 +60,46 @@
     <url>http://java.sun.com/projects/javamail</url>
 
     <properties>
+ <m64>
+ </m64>
         <compiler.name>
             c89
         </compiler.name>
         <compiler.start.options>
- -Xa -xO2 -v -D_REENTRANT
+ ${m64} -Xa -xO2 -v -D_REENTRANT -KPIC
             -I${env.JAVA_HOME}/include -I${env.JAVA_HOME}/include/solaris
         </compiler.start.options>
         <linker.name>
             c89
         </linker.name>
         <linker.start.options>
- -G
+ -G ${m64} -KPIC -z text
         </linker.start.options>
+ <linker.arch>
+ ${env.MACH}
+ </linker.arch>
         <linker.end.options>
- -L${env.JAVA_HOME}/jre/lib/${env.MACH} -lmail -ljava -lc
+ -L${env.JAVA_HOME}/jre/lib/${linker.arch} -lmail -ljava -lc
         </linker.end.options>
     </properties>
 
+ <profiles>
+ <profile>
+ <!--
+ Override the settings necessary to build with JDK 1.8.
+ -->
+ <id>1.8</id>
+ <properties>
+ <m64>
+ -m64
+ </m64>
+ <linker.arch>
+ amd64
+ </linker.arch>
+ </properties>
+ </profile>
+ </profiles>
+
     <build>
         <plugins>
             <plugin>


diff -r ec8cf1942372 -r 8de9c39e5b25 doc/release/CHANGES.txt
--- a/doc/release/CHANGES.txt Wed Jun 24 11:41:59 2015 -0700
+++ b/doc/release/CHANGES.txt Fri Jun 26 16:42:47 2015 -0700
@@ -14,6 +14,13 @@
         https://kenai.com/bugzilla/
 
 
+ CHANGES IN THE 1.5.5 RELEASE
+ ----------------------------
+The following bugs have been fixed in the 1.5.5 release.
+
+K 6886 add support for setting GMail labels on messages
+
+
                   CHANGES IN THE 1.5.4 RELEASE
                   ----------------------------
 The following bugs have been fixed in the 1.5.4 release.

diff -r ec8cf1942372 -r 8de9c39e5b25 gimap/src/main/java/com/sun/mail/gimap/GmailFolder.java
--- a/gimap/src/main/java/com/sun/mail/gimap/GmailFolder.java Wed Jun 24 11:41:59 2015 -0700
+++ b/gimap/src/main/java/com/sun/mail/gimap/GmailFolder.java Fri Jun 26 16:42:47 2015 -0700
@@ -1,7 +1,7 @@
 /*
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
  *
- * Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2015 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,6 +48,7 @@
 import com.sun.mail.iap.*;
 import com.sun.mail.imap.*;
 import com.sun.mail.imap.protocol.*;
+import com.sun.mail.gimap.protocol.*;
 
 /**
  * A Gmail folder. Defines new FetchProfile items and
@@ -126,6 +127,79 @@
     }
 
     /**
+ * Set the specified labels for the given array of messages.
+ *
+ * @param msgs the messages
+ * @param labels the labels to add or remove
+ * @param set true to add, false to remove
+ * @exception MessagingException for failures
+ * @since JavaMail 1.5.5
+ */
+ public synchronized void setLabels(Message[] msgs,
+ String[] labels, boolean set)
+ throws MessagingException {
+ checkOpened();
+
+ if (msgs.length == 0) // boundary condition
+ return;
+
+ synchronized(messageCacheLock) {
+ try {
+ GmailProtocol p = (GmailProtocol)getProtocol();
+ MessageSet[] ms = Utility.toMessageSetSorted(msgs, null);
+ if (ms == null)
+ throw new MessageRemovedException(
+ "Messages have been removed");
+ p.storeLabels(ms, labels, set);
+ } catch (ConnectionException cex) {
+ throw new FolderClosedException(this, cex.getMessage());
+ } catch (ProtocolException pex) {
+ throw new MessagingException(pex.getMessage(), pex);
+ }
+ }
+ }
+
+ /**
+ * Set the specified labels for the given range of message numbers.
+ *
+ * @param start first message number
+ * @param end last message number
+ * @param labels the labels to add or remove
+ * @param set true to add, false to remove
+ * @exception MessagingException for failures
+ * @since JavaMail 1.5.5
+ */
+ public synchronized void setLabels(int start, int end,
+ String[] labels, boolean set)
+ throws MessagingException {
+ checkOpened();
+ Message[] msgs = new Message[end - start + 1];
+ int i = 0;
+ for (int n = start; n <= end; n++)
+ msgs[i++] = getMessage(n);
+ setLabels(msgs, labels, set);
+ }
+
+ /**
+ * Set the specified labels for the given array of message numbers.
+ *
+ * @param msgnums the message numbers
+ * @param labels the labels to add or remove
+ * @param set true to add, false to remove
+ * @exception MessagingException for failures
+ * @since JavaMail 1.5.5
+ */
+ public synchronized void setLabels(int[] msgnums,
+ String[] labels, boolean set)
+ throws MessagingException {
+ checkOpened();
+ Message[] msgs = new Message[msgnums.length];
+ for (int i = 0; i < msgnums.length; i++)
+ msgs[i] = getMessage(msgnums[i]);
+ setLabels(msgs, labels, set);
+ }
+
+ /**
      * Constructor used to create a possibly non-existent folder.
      *
      * @param fullName fullname of this folder

diff -r ec8cf1942372 -r 8de9c39e5b25 gimap/src/main/java/com/sun/mail/gimap/GmailMessage.java
--- a/gimap/src/main/java/com/sun/mail/gimap/GmailMessage.java Wed Jun 24 11:41:59 2015 -0700
+++ b/gimap/src/main/java/com/sun/mail/gimap/GmailMessage.java Fri Jun 26 16:42:47 2015 -0700
@@ -1,7 +1,7 @@
 /*
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
  *
- * Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2015 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
@@ -120,4 +120,27 @@
             return new String[0];
     }
 
+ /**
+ * Set/Unset the given labels on this message.
+ *
+ * @param labels the labels to add or remove
+ * @param set true to add labels, false to remove
+ * @exception MessagingException for failures
+ * @since JavaMail 1.5.5
+ */
+ public synchronized void setLabels(String[] labels, boolean set)
+ throws MessagingException {
+ // Acquire MessageCacheLock, to freeze seqnum.
+ synchronized(getMessageCacheLock()) {
+ try {
+ GmailProtocol p = (GmailProtocol)getProtocol();
+ checkExpunged(); // Insure that this message is not expunged
+ p.storeLabels(getSequenceNumber(), labels, set);
+ } catch (ConnectionException cex) {
+ throw new FolderClosedException(folder, cex.getMessage());
+ } catch (ProtocolException pex) {
+ throw new MessagingException(pex.getMessage(), pex);
+ }
+ }
+ }
 }

diff -r ec8cf1942372 -r 8de9c39e5b25 gimap/src/main/java/com/sun/mail/gimap/protocol/GmailProtocol.java
--- a/gimap/src/main/java/com/sun/mail/gimap/protocol/GmailProtocol.java Wed Jun 24 11:41:59 2015 -0700
+++ b/gimap/src/main/java/com/sun/mail/gimap/protocol/GmailProtocol.java Fri Jun 26 16:42:47 2015 -0700
@@ -134,6 +134,74 @@
     }
 
     /**
+ * Set the specified labels on this message.
+ *
+ * @param msgsets the message sets
+ * @param labels the labels
+ * @param set true to set, false to clear
+ * @exception ProtocolException for protocol failures
+ * @since JavaMail 1.5.5
+ */
+ public void storeLabels(MessageSet[] msgsets, String[] labels, boolean set)
+ throws ProtocolException {
+ storeLabels(MessageSet.toString(msgsets), labels, set);
+ }
+
+ /**
+ * Set the specified labels on this message.
+ *
+ * @param start the first message number
+ * @param end the last message number
+ * @param labels the labels
+ * @param set true to set, false to clear
+ * @exception ProtocolException for protocol failures
+ * @since JavaMail 1.5.5
+ */
+ public void storeLabels(int start, int end, String[] labels, boolean set)
+ throws ProtocolException {
+ storeLabels(String.valueOf(start) + ":" + String.valueOf(end),
+ labels, set);
+ }
+
+ /**
+ * Set the specified labels on this message.
+ *
+ * @param msg the message number
+ * @param labels the labels
+ * @param set true to set, false to clear
+ * @exception ProtocolException for protocol failures
+ * @since JavaMail 1.5.5
+ */
+ public void storeLabels(int msg, String[] labels, boolean set)
+ throws ProtocolException {
+ storeLabels(String.valueOf(msg), labels, set);
+ }
+
+ private void storeLabels(String msgset, String[] labels, boolean set)
+ throws ProtocolException {
+ Response[] r;
+ if (set)
+ r = command("STORE " + msgset + " +X-GM-LABELS",
+ createLabelList(labels));
+ else
+ r = command("STORE " + msgset + " -X-GM-LABELS",
+ createLabelList(labels));
+
+ // Dispatch untagged responses
+ notifyResponseHandlers(r);
+ handleResult(r[r.length-1]);
+ }
+
+ private Argument createLabelList(String[] labels) {
+ Argument args = new Argument();
+ Argument itemArgs = new Argument();
+ for (int i = 0, len = labels.length; i < len; i++)
+ itemArgs.writeAtom(labels[i]);
+ args.writeArgument(itemArgs);
+ return args;
+ }
+
+ /**
      * Return a GmailSearchSequence.
      */
     protected SearchSequence getSearchSequence() {

diff -r ec8cf1942372 -r 8de9c39e5b25 mail/src/main/java/com/sun/mail/imap/IMAPFolder.java
--- a/mail/src/main/java/com/sun/mail/imap/IMAPFolder.java Wed Jun 24 11:41:59 2015 -0700
+++ b/mail/src/main/java/com/sun/mail/imap/IMAPFolder.java Fri Jun 26 16:42:47 2015 -0700
@@ -3477,6 +3477,10 @@
                 notify = true;
             }
 
+ // handle any extension items that might've changed
+ // XXX - no notifications associated with extension items
+ msg.handleExtensionFetchItems(fr.getExtensionItems());
+
             if (!notify)
                 msg = null;
         }

diff -r ec8cf1942372 -r 8de9c39e5b25 mail/src/main/java/com/sun/mail/imap/IMAPMessage.java
--- a/mail/src/main/java/com/sun/mail/imap/IMAPMessage.java Wed Jun 24 11:41:59 2015 -0700
+++ b/mail/src/main/java/com/sun/mail/imap/IMAPMessage.java Fri Jun 26 16:42:47 2015 -0700
@@ -1299,8 +1299,9 @@
      * @exception MessagingException for failures
      * @since JavaMail 1.4.6
      */
- protected void handleExtensionFetchItems(Map extensionItems)
- throws MessagingException {
+ protected void handleExtensionFetchItems(Map extensionItems) {
+ if (extensionItems == null || extensionItems.isEmpty())
+ return;
         if (items == null)
             items = new HashMap();
         items.putAll(extensionItems);

diff -r ec8cf1942372 -r 8de9c39e5b25 mail/src/main/java/com/sun/mail/imap/protocol/FetchResponse.java
--- a/mail/src/main/java/com/sun/mail/imap/protocol/FetchResponse.java Wed Jun 24 11:41:59 2015 -0700
+++ b/mail/src/main/java/com/sun/mail/imap/protocol/FetchResponse.java Fri Jun 26 16:42:47 2015 -0700
@@ -185,12 +185,10 @@
      * The map is indexed by extension item name. Callers should not
      * modify the map.
      *
- * @return MAP of extension items
+ * @return Map of extension items, or null if none
      * @since JavaMail 1.4.6
      */
     public Map getExtensionItems() {
- if (extensionItems == null)
- extensionItems = new HashMap();
         return extensionItems;
     }
 
@@ -299,7 +297,9 @@
             return false;
         for (int i = 0; i < fitems.length; i++) {
             if (match(fitems[i].getName())) {
- getExtensionItems().put(fitems[i].getName(),
+ if (extensionItems == null)
+ extensionItems = new HashMap();
+ extensionItems.put(fitems[i].getName(),
                                     fitems[i].parseItem(this));
                 return true;
             }


diff -r 8de9c39e5b25 -r 6aab31e3f747 mail/src/test/java/com/sun/mail/smtp/SMTPIOExceptionTest.java
--- a/mail/src/test/java/com/sun/mail/smtp/SMTPIOExceptionTest.java Fri Jun 26 16:42:47 2015 -0700
+++ b/mail/src/test/java/com/sun/mail/smtp/SMTPIOExceptionTest.java Wed Jul 01 12:03:12 2015 -0700
@@ -1,7 +1,7 @@
 /*
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
  *
- * Copyright (c) 2009-2014 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009-2015 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
@@ -42,6 +42,7 @@
 
 import java.io.IOException;
 import java.util.Properties;
+import java.util.concurrent.CountDownLatch;
 
 import javax.mail.Session;
 import javax.mail.Transport;
@@ -75,6 +76,7 @@
     @Test
     public void test() throws Exception {
         TestServer server = null;
+ final CountDownLatch closedLatch = new CountDownLatch(1);
         try {
             SMTPHandler handler = new SMTPHandler() {
                 public void rcpt() throws IOException {
@@ -87,7 +89,6 @@
             };
             server = new TestServer(handler);
             server.start();
- Thread.sleep(1000);
 
             final Properties properties = new Properties();
             properties.setProperty("mail.smtp.host", "localhost");
@@ -107,7 +108,7 @@
             t.addConnectionListener(new ConnectionAdapter() {
                 @Override
                 public void closed(ConnectionEvent e) {
- setClosed(true);
+ closedLatch.countDown();
                 }
             });
             try {
@@ -119,8 +120,8 @@
                 t.sendMessage(msg, msg.getAllRecipients());
             } catch (MessagingException ex) {
                 // expect an exception from sendMessage
- Thread.sleep(100); // give event thread time to run
- assertTrue(getClosed());
+ closedLatch.await(); // wait for the listener to run
+ // if we get here, the listener was called - SUCCESS
             } finally {
                 t.close();
             }
@@ -131,17 +132,9 @@
             if (server != null) {
                 server.quit();
                 server.interrupt();
- // wait long enough for handler to exit
- Thread.sleep(2 * TIMEOUT);
+ // wait for handler to exit
+ server.join();
             }
         }
     }
-
- private synchronized void setClosed(boolean v) {
- closed = v;
- }
-
- private synchronized boolean getClosed() {
- return closed;
- }
 }


diff -r 6aab31e3f747 -r 6cae0b4fe5fb mail/src/test/java/com/sun/mail/imap/IMAPIdleManagerTest.java
--- a/mail/src/test/java/com/sun/mail/imap/IMAPIdleManagerTest.java Wed Jul 01 12:03:12 2015 -0700
+++ b/mail/src/test/java/com/sun/mail/imap/IMAPIdleManagerTest.java Wed Jul 01 12:03:48 2015 -0700
@@ -181,7 +181,6 @@
     private void testFailure(IMAPHandlerIdle handler, boolean setTimeout) {
         TestServer server = null;
         IdleManager idleManager = null;
- final CountDownLatch closedLatch = new CountDownLatch(1);
         try {
             server = new TestServer(handler);
             server.start();


diff -r 6cae0b4fe5fb -r 0de68301c202 mail/src/main/java/com/sun/mail/imap/IdleManager.java
--- a/mail/src/main/java/com/sun/mail/imap/IdleManager.java Wed Jul 01 12:03:48 2015 -0700
+++ b/mail/src/main/java/com/sun/mail/imap/IdleManager.java Wed Jul 22 15:30:22 2015 -0700
@@ -176,6 +176,8 @@
      */
     public synchronized void watch(Folder folder)
                                 throws MessagingException {
+ if (die) // XXX - should be IllegalStateException?
+ throw new MessagingException("IdleManager is not running");
         if (!(folder instanceof IMAPFolder))
             throw new MessagingException("Can only watch IMAP folders");
         IMAPFolder ifolder = (IMAPFolder)folder;


diff -r 0de68301c202 -r a1fa767f96db mail/src/main/java/com/sun/mail/iap/Protocol.java
--- a/mail/src/main/java/com/sun/mail/iap/Protocol.java Wed Jul 22 15:30:22 2015 -0700
+++ b/mail/src/main/java/com/sun/mail/iap/Protocol.java Wed Jul 22 15:31:45 2015 -0700
@@ -565,8 +565,11 @@
      * Finalizer.
      */
     protected void finalize() throws Throwable {
- super.finalize();
- disconnect();
+ try {
+ disconnect();
+ } finally {
+ super.finalize();
+ }
     }
 
     /*

diff -r 0de68301c202 -r a1fa767f96db mail/src/main/java/com/sun/mail/imap/IMAPStore.java
--- a/mail/src/main/java/com/sun/mail/imap/IMAPStore.java Wed Jul 22 15:30:22 2015 -0700
+++ b/mail/src/main/java/com/sun/mail/imap/IMAPStore.java Wed Jul 22 15:31:45 2015 -0700
@@ -1,7 +1,7 @@
 /*
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
  *
- * Copyright (c) 1997-2014 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2015 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
@@ -1593,8 +1593,11 @@
     }
 
     protected void finalize() throws Throwable {
- super.finalize();
- close();
+ try {
+ close();
+ } finally {
+ super.finalize();
+ }
     }
 
     /**

diff -r 0de68301c202 -r a1fa767f96db mail/src/main/java/com/sun/mail/pop3/POP3Folder.java
--- a/mail/src/main/java/com/sun/mail/pop3/POP3Folder.java Wed Jul 22 15:30:22 2015 -0700
+++ b/mail/src/main/java/com/sun/mail/pop3/POP3Folder.java Wed Jul 22 15:31:45 2015 -0700
@@ -548,8 +548,12 @@
      * Close the folder when we're finalized.
      */
     protected void finalize() throws Throwable {
- super.finalize();
- close(false);
+ try {
+ if (opened)
+ close(false);
+ } finally {
+ super.finalize();
+ }
     }
 
     /* Ensure the folder is open */

diff -r 0de68301c202 -r a1fa767f96db mail/src/main/java/com/sun/mail/pop3/POP3Store.java
--- a/mail/src/main/java/com/sun/mail/pop3/POP3Store.java Wed Jul 22 15:30:22 2015 -0700
+++ b/mail/src/main/java/com/sun/mail/pop3/POP3Store.java Wed Jul 22 15:31:45 2015 -0700
@@ -1,7 +1,7 @@
 /*
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
  *
- * Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2015 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
@@ -408,10 +408,12 @@
     }
 
     protected void finalize() throws Throwable {
- super.finalize();
-
- if (port != null) // don't force a connection attempt
- close();
+ try {
+ if (port != null) // don't force a connection attempt
+ close();
+ } finally {
+ super.finalize();
+ }
     }
 
     private void checkConnected() throws MessagingException {

diff -r 0de68301c202 -r a1fa767f96db mail/src/main/java/com/sun/mail/pop3/Protocol.java
--- a/mail/src/main/java/com/sun/mail/pop3/Protocol.java Wed Jul 22 15:30:22 2015 -0700
+++ b/mail/src/main/java/com/sun/mail/pop3/Protocol.java Wed Jul 22 15:31:45 2015 -0700
@@ -177,9 +177,11 @@
     }
 
     protected void finalize() throws Throwable {
- super.finalize();
- if (socket != null) { // Forgot to logout ?!
- quit();
+ try {
+ if (socket != null) // Forgot to logout ?!
+ quit();
+ } finally {
+ super.finalize();
         }
     }
 

diff -r 0de68301c202 -r a1fa767f96db mail/src/main/java/com/sun/mail/pop3/TempFile.java
--- a/mail/src/main/java/com/sun/mail/pop3/TempFile.java Wed Jul 22 15:30:22 2015 -0700
+++ b/mail/src/main/java/com/sun/mail/pop3/TempFile.java Wed Jul 22 15:31:45 2015 -0700
@@ -1,7 +1,7 @@
 /*
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
  *
- * Copyright (c) 2010-2011 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010-2015 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
@@ -87,8 +87,11 @@
     }
 
     protected void finalize() throws Throwable {
- super.finalize();
- close();
+ try {
+ close();
+ } finally {
+ super.finalize();
+ }
     }
 }
 

diff -r 0de68301c202 -r a1fa767f96db mail/src/main/java/com/sun/mail/smtp/SMTPTransport.java
--- a/mail/src/main/java/com/sun/mail/smtp/SMTPTransport.java Wed Jul 22 15:30:22 2015 -0700
+++ b/mail/src/main/java/com/sun/mail/smtp/SMTPTransport.java Wed Jul 22 15:31:45 2015 -0700
@@ -1523,11 +1523,12 @@
     }
 
     protected void finalize() throws Throwable {
- super.finalize();
         try {
             closeConnection();
         } catch (MessagingException mex) {
             // ignore it
+ } finally {
+ super.finalize();
         }
     }
 

diff -r 0de68301c202 -r a1fa767f96db mail/src/main/java/javax/mail/Folder.java
--- a/mail/src/main/java/javax/mail/Folder.java Wed Jul 22 15:30:22 2015 -0700
+++ b/mail/src/main/java/javax/mail/Folder.java Wed Jul 22 15:31:45 2015 -0700
@@ -1,7 +1,7 @@
 /*
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
  *
- * Copyright (c) 1997-2014 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2015 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
@@ -1631,8 +1631,11 @@
     }
 
     protected void finalize() throws Throwable {
- super.finalize();
- q.terminateQueue();
+ try {
+ q.terminateQueue();
+ } finally {
+ super.finalize();
+ }
     }
 
     /**

diff -r 0de68301c202 -r a1fa767f96db mail/src/main/java/javax/mail/Service.java
--- a/mail/src/main/java/javax/mail/Service.java Wed Jul 22 15:30:22 2015 -0700
+++ b/mail/src/main/java/javax/mail/Service.java Wed Jul 22 15:31:45 2015 -0700
@@ -1,7 +1,7 @@
 /*
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
  *
- * Copyright (c) 1997-2014 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2015 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
@@ -651,8 +651,11 @@
      * Stop the event dispatcher thread so the queue can be garbage collected.
      */
     protected void finalize() throws Throwable {
- super.finalize();
- q.terminateQueue();
+ try {
+ q.terminateQueue();
+ } finally {
+ super.finalize();
+ }
     }
 
     /**

diff -r 0de68301c202 -r a1fa767f96db mail/src/main/java/javax/mail/util/SharedFileInputStream.java
--- a/mail/src/main/java/javax/mail/util/SharedFileInputStream.java Wed Jul 22 15:30:22 2015 -0700
+++ b/mail/src/main/java/javax/mail/util/SharedFileInputStream.java Wed Jul 22 15:31:45 2015 -0700
@@ -144,8 +144,11 @@
         }
 
         protected void finalize() throws Throwable {
- super.finalize();
- in.close();
+ try {
+ in.close();
+ } finally {
+ super.finalize();
+ }
         }
     }
 

diff -r 0de68301c202 -r a1fa767f96db mbox/src/main/java/com/sun/mail/mbox/TempFile.java
--- a/mbox/src/main/java/com/sun/mail/mbox/TempFile.java Wed Jul 22 15:30:22 2015 -0700
+++ b/mbox/src/main/java/com/sun/mail/mbox/TempFile.java Wed Jul 22 15:31:45 2015 -0700
@@ -1,7 +1,7 @@
 /*
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
  *
- * Copyright (c) 2010-2011 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010-2015 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,8 +94,11 @@
     }
 
     protected void finalize() throws Throwable {
- super.finalize();
- close();
+ try {
+ close();
+ } finally {
+ super.finalize();
+ }
     }
 }
 


diff -r a1fa767f96db -r 84f44ae804cc mail/src/main/java/com/sun/mail/util/SocketFetcher.java
--- a/mail/src/main/java/com/sun/mail/util/SocketFetcher.java Wed Jul 22 15:31:45 2015 -0700
+++ b/mail/src/main/java/com/sun/mail/util/SocketFetcher.java Wed Aug 05 12:29:59 2015 -0700
@@ -339,7 +339,8 @@
          * If we want an SSL connection and we didn't get an SSLSocket,
          * wrap our plain Socket with an SSLSocket.
          */
- if (useSSL && !(socket instanceof SSLSocket)) {
+ if ((useSSL || sf instanceof SSLSocketFactory) &&
+ !(socket instanceof SSLSocket)) {
             String trusted;
             SSLSocketFactory ssf;
             if ((trusted = props.getProperty(prefix + ".ssl.trust")) != null) {


diff -r 84f44ae804cc -r cae15bd907ac mail/src/main/java/javax/mail/internet/NewMailDateFormat.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mail/src/main/java/javax/mail/internet/NewMailDateFormat.java Tue Aug 04 20:11:50 2015 +0200
@@ -0,0 +1,1061 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 1997-2015 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.
+ */
+
+package javax.mail.internet;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectStreamException;
+import java.util.Date;
+import java.util.Calendar;
+import java.util.Locale;
+import java.util.TimeZone;
+import java.util.logging.Level;
+import java.text.SimpleDateFormat;
+import java.text.NumberFormat;
+import java.text.FieldPosition;
+import java.text.ParsePosition;
+import java.text.ParseException;
+
+import com.sun.mail.util.MailLogger;
+
+/**
+ * Formats and parses date specification based on
+ * <a href="http://www.ietf.org/rfc/rfc2822.txt">RFC 2822</a>. <p>
+ *
+ * This class does not support methods that influence the format. It always
+ * formats the date based on the specification below.<p>
+ *
+ * 3.3. Date and Time Specification
+ * <p>
+ * Date and time occur in several header fields. This section specifies
+ * the syntax for a full date and time specification. Though folding
+ * white space is permitted throughout the date-time specification, it is
+ * RECOMMENDED that a single space be used in each place that FWS appears
+ * (whether it is required or optional); some older implementations may
+ * not interpret other occurrences of folding white space correctly.
+ * <pre>
+ * date-time = [ day-of-week "," ] date FWS time [CFWS]
+ *
+ * day-of-week = ([FWS] day-name) / obs-day-of-week
+ *
+ * day-name = "Mon" / "Tue" / "Wed" / "Thu" /
+ * "Fri" / "Sat" / "Sun"
+ *
+ * date = day month year
+ *
+ * year = 4*DIGIT / obs-year
+ *
+ * month = (FWS month-name FWS) / obs-month
+ *
+ * month-name = "Jan" / "Feb" / "Mar" / "Apr" /
+ * "May" / "Jun" / "Jul" / "Aug" /
+ * "Sep" / "Oct" / "Nov" / "Dec"
+ *
+ * day = ([FWS] 1*2DIGIT) / obs-day
+ *
+ * time = time-of-day FWS zone
+ *
+ * time-of-day = hour ":" minute [ ":" second ]
+ *
+ * hour = 2DIGIT / obs-hour
+ *
+ * minute = 2DIGIT / obs-minute
+ *
+ * second = 2DIGIT / obs-second
+ *
+ * zone = (( "+" / "-" ) 4DIGIT) / obs-zone
+ * </pre>
+ * The day is the numeric day of the month. The year is any numeric year
+ * 1900 or later.
+ * <p>
+ * The time-of-day specifies the number of hours, minutes, and optionally
+ * seconds since midnight of the date indicated.
+ * <p>
+ * The date and time-of-day SHOULD express local time.
+ * <p>
+ * The zone specifies the offset from Coordinated Universal Time (UTC,
+ * formerly referred to as "Greenwich Mean Time") that the date and
+ * time-of-day represent. The "+" or "-" indicates whether the
+ * time-of-day is ahead of (i.e., east of) or behind (i.e., west of)
+ * Universal Time. The first two digits indicate the number of hours
+ * difference from Universal Time, and the last two digits indicate the
+ * number of minutes difference from Universal Time. (Hence, +hhmm means
+ * +(hh * 60 + mm) minutes, and -hhmm means -(hh * 60 + mm) minutes). The
+ * form "+0000" SHOULD be used to indicate a time zone at Universal Time.
+ * Though "-0000" also indicates Universal Time, it is used to indicate
+ * that the time was generated on a system that may be in a local time
+ * zone other than Universal Time and therefore indicates that the
+ * date-time contains no information about the local time zone.
+ * <p>
+ * A date-time specification MUST be semantically valid. That is, the
+ * day-of-the-week (if included) MUST be the day implied by the date, the
+ * numeric day-of-month MUST be between 1 and the number of days allowed
+ * for the specified month (in the specified year), the time-of-day MUST
+ * be in the range 00:00:00 through 23:59:60 (the number of seconds
+ * allowing for a leap second; see [STD12]), and the zone MUST be within
+ * the range -9959 through +9959.
+ *
+ * <h3><a name="synchronization">Synchronization</a></h3>
+ *
+ * <p>
+ * Date formats are not synchronized.
+ * It is recommended to create separate format instances for each thread.
+ * If multiple threads access a format concurrently, it must be synchronized
+ * externally.
+ *
+ * @author Anthony Vanelverdinghe
+ * @author Max Spivak
+ * @since JavaMail 1.2
+ */
+public class NewMailDateFormat extends SimpleDateFormat {
+
+ private static final long serialVersionUID = -8148227605210628779L;
+ private static final String PATTERN = "EEE, d MMM yyyy HH:mm:ss Z (z)";
+
+ private static final MailLogger LOGGER = new MailLogger(
+ NewMailDateFormat.class, "DEBUG", false, System.out);
+
+ private static final int UNKNOWN_DAY_NAME = -1;
+ private static final TimeZone UTC = TimeZone.getTimeZone("UTC");
+ private static final int LEAP_SECOND = 60;
+
+ /**
+ * Create a new date format for the RFC2822 specification with lenient
+ * parsing.
+ */
+ public NewMailDateFormat() {
+ super(PATTERN, Locale.US);
+ }
+
+ /**
+ * Allows to serialize instances such that they are deserializable with the
+ * previous implementation.
+ *
+ * @return the object to be serialized
+ * @throws ObjectStreamException
+ */
+ private Object writeReplace() throws ObjectStreamException {
+ NewMailDateFormat fmt = new NewMailDateFormat();
+ fmt.superApplyPattern("EEE, d MMM yyyy HH:mm:ss 'XXXXX' (z)");
+ fmt.setTimeZone(getTimeZone());
+ return fmt;
+ }
+
+ /**
+ * Allows to deserialize instances that were serialized with the previous
+ * implementation.
+ *
+ * @param in the stream containing the serialized object
+ * @throws IOException
+ * @throws ClassNotFoundException
+ */
+ private void readObject(ObjectInputStream in)
+ throws IOException, ClassNotFoundException {
+ in.defaultReadObject();
+ super.applyPattern(PATTERN);
+ }
+
+ /**
+ * Overrides Cloneable.
+ *
+ * @return a clone of this instance
+ */
+// @Override
+// public NewMailDateFormat clone() {
+// return (NewMailDateFormat) super.clone();
+// }
+
+ /**
+ * Formats the given date in the format specified by
+ * RFC 2822 in the current TimeZone.
+ *
+ * @param date the Date object
+ * @param dateStrBuf the formatted string
+ * @param fieldPosition the current field position
+ * @return StringBuffer the formatted String
+ * @since JavaMail 1.2
+ */
+ @Override
+ public StringBuffer format(Date date, StringBuffer dateStrBuf,
+ FieldPosition fieldPosition) {
+ return super.format(date, dateStrBuf, fieldPosition);
+ }
+
+ /**
+ * Parses the given date in the format specified by
+ * RFC 2822.
+ * <p>
+ * <ul>
+ * <li>With strict parsing, obs-* tokens are unsupported. Lenient parsing
+ * supports obs-year and obs-zone, with the exception of the 1-character
+ * military time zones.
+ * <li>The optional CFWS token at the end is not parsed.
+ * <li>RFC 2822 specifies that a zone of "-0000" indicates that the
+ * date-time contains no information about the local time zone. This class
+ * uses the UTC time zone in this case.
+ * </ul>
+ *
+ * @param text the formatted date to be parsed
+ * @param pos the current parse position
+ * @return Date the parsed date. In case of error, returns null.
+ * @since JavaMail 1.2
+ */
+ @Override
+ public Date parse(String text, ParsePosition pos) {
+ if (text == null || pos == null) {
+ throw new NullPointerException();
+ } else if (0 > pos.getIndex() || pos.getIndex() >= text.length()) {
+ return null;
+ }
+
+ return isLenient()
+ ? new Rfc2822LenientParser(text, pos).parse()
+ : new Rfc2822StrictParser(text, pos).parse();
+ }
+
+ /**
+ * This method always throws an UnsupportedOperationException and should not
+ * be used because RFC 2822 mandates a specific calendar.
+ *
+ * @throws UnsupportedOperationException if this method is invoked
+ */
+ @Override
+ public void setCalendar(Calendar newCalendar) {
+ throw new UnsupportedOperationException("Method "
+ + "setCalendar() shouldn't be called");
+ }
+
+ /**
+ * This method always throws an UnsupportedOperationException and should not
+ * be used because RFC 2822 mandates a specific number format.
+ *
+ * @throws UnsupportedOperationException if this method is invoked
+ */
+ @Override
+ public void setNumberFormat(NumberFormat newNumberFormat) {
+ throw new UnsupportedOperationException("Method "
+ + "setNumberFormat() shouldn't be called");
+ }
+
+ /**
+ * This method always throws an UnsupportedOperationException and should not
+ * be used because RFC 2822 mandates a specific pattern.
+ *
+ * @throws UnsupportedOperationException if this method is invoked
+ */
+// @Override
+// public void applyLocalizedPattern(String pattern) {
+// throw new UnsupportedOperationException("Method "
+// + "applyLocalizedPattern() shouldn't be called");
+// }
+
+ /**
+ * This method always throws an UnsupportedOperationException and should not
+ * be used because RFC 2822 mandates a specific pattern.
+ *
+ * @throws UnsupportedOperationException if this method is invoked
+ */
+// @Override
+// public void applyPattern(String pattern) {
+// throw new UnsupportedOperationException("Method "
+// + "applyPattern() shouldn't be called");
+// }
+
+ /**
+ * This method allows serialization to change the pattern.
+ */
+ private void superApplyPattern(String pattern) {
+ super.applyPattern(pattern);
+ }
+
+ /**
+ * This method always throws an UnsupportedOperationException and should not
+ * be used because RFC 2822 mandates another strategy for interpreting
+ * 2-digits years.
+ *
+ * @return the start of the 100-year period into which two digit years are
+ * parsed
+ * @throws UnsupportedOperationException if this method is invoked
+ */
+// @Override
+// public Date get2DigitYearStart() {
+// throw new UnsupportedOperationException("Method "
+// + "get2DigitYearStart() shouldn't be called");
+// }
+
+ /**
+ * This method always throws an UnsupportedOperationException and should not
+ * be used because RFC 2822 mandates another strategy for interpreting
+ * 2-digits years.
+ *
+ * @throws UnsupportedOperationException if this method is invoked
+ */
+// @Override
+// public void set2DigitYearStart(Date startDate) {
+// throw new UnsupportedOperationException("Method "
+// + "set2DigitYearStart() shouldn't be called");
+// }
+
+ /**
+ * This method always throws an UnsupportedOperationException and should not
+ * be used because RFC 2822 mandates specific date format symbols.
+ *
+ * @throws UnsupportedOperationException if this method is invoked
+ */
+// @Override
+// public void setDateFormatSymbols(DateFormatSymbols newFormatSymbols) {
+// throw new UnsupportedOperationException("Method "
+// + "setDateFormatSymbols() shouldn't be called");
+// }
+
+ /**
+ * Returns the date, as specified by the parameters.
+ *
+ * @param dayName
+ * @param day
+ * @param month
+ * @param year
+ * @param hour
+ * @param minute
+ * @param second
+ * @param zone
+ * @return the date, as specified by the parameters
+ * @throws IllegalArgumentException if this instance's Calendar is
+ * non-lenient and any of the parameters have invalid values, or if dayName
+ * is not consistent with day-month-year
+ */
+ private Date toDate(int dayName, int day, int month, int year,
+ int hour, int minute, int second, int zone) {
+ if (second =
[truncated due to length]