commits@javamail.java.net

[javamail~mercurial:791] Need to use <compilerArgs> so that overriding works properly.

From: <shannon_at_java.net>
Date: Thu, 22 Oct 2015 22:08:18 +0000

Project: javamail
Repository: mercurial
Revision: 791
Author: shannon
Date: 2015-10-22 06:52:53 UTC
Link:

Log Message:
------------
Status class doesn't decode mailbox name - bug 7030
Oops, keep trying if first port fails.
Upgrade to JUnit 4.12.

(From Anthony)
add support for IMAP COMPRESS extension (RFC 4978) - bug 7035
Fix javac warnings, except finally
Eliminate uses of Vector, Hashtable, Enumeration
Fix compilation issues on JDK 1.5:
No -Werror option to javac.
No DeflaterOutpuStream(OutputStream, Deflater, boolean) constructor.
Fix warning from -Werror that occurs on JDK 1.7 but not JDK 1.8.
Need to use <compilerArgs> so that overriding works properly.


Revisions:
----------
783
784
785
786
787
788
789
790
791


Modified Paths:
---------------
doc/release/CHANGES.txt
mail/src/main/java/com/sun/mail/imap/protocol/Status.java
mail/src/test/java/com/sun/mail/test/TestServer.java
mail/pom.xml
mail/src/test/java/com/sun/mail/imap/IMAPAuthDebugTest.java
mail/src/test/java/com/sun/mail/imap/IMAPIDTest.java
mail/src/test/java/com/sun/mail/imap/IMAPIdleManagerTest.java
mail/src/test/java/com/sun/mail/imap/IMAPIdleStateTest.java
mail/src/test/java/com/sun/mail/imap/IMAPIdleUntaggedResponseTest.java
mail/src/test/java/com/sun/mail/imap/IMAPLoginReferralTest.java
mail/src/test/java/com/sun/mail/imap/IMAPMessageNumberOutOfRangeTest.java
mail/src/test/java/com/sun/mail/imap/IMAPUidExpungeTest.java
mail/src/test/java/com/sun/mail/pop3/POP3AuthDebugTest.java
mail/src/test/java/com/sun/mail/smtp/SMTPAuthDebugTest.java
mail/src/test/java/com/sun/mail/smtp/SMTPCloseTest.java
mail/src/test/java/com/sun/mail/smtp/SMTPIOExceptionTest.java
mail/src/test/java/com/sun/mail/smtp/SMTPWriteTimeoutTest.java
mail/src/test/java/com/sun/mail/util/WriteTimeoutSocketTest.java
mail/src/test/java/com/sun/mail/util/logging/LogManagerPropertiesTest.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/imap/package.html
mail/src/main/java/com/sun/mail/imap/protocol/IMAPProtocol.java
mail/src/main/java/com/sun/mail/iap/Argument.java
mail/src/main/java/com/sun/mail/iap/Response.java
mail/src/main/java/com/sun/mail/imap/IMAPBodyPart.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/IMAPMultipartDataSource.java
mail/src/main/java/com/sun/mail/imap/MessageCache.java
mail/src/main/java/com/sun/mail/imap/Rights.java
mail/src/main/java/com/sun/mail/imap/Utility.java
mail/src/main/java/com/sun/mail/imap/protocol/FetchResponse.java
mail/src/main/java/com/sun/mail/imap/protocol/IMAPSaslAuthenticator.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/pop3/TempFile.java
mail/src/main/java/com/sun/mail/smtp/DigestMD5.java
mail/src/main/java/com/sun/mail/smtp/SMTPSaslAuthenticator.java
mail/src/main/java/com/sun/mail/smtp/SMTPTransport.java
mail/src/main/java/com/sun/mail/util/MimeUtil.java
mail/src/main/java/com/sun/mail/util/SocketFetcher.java
mail/src/main/java/javax/mail/EventQueue.java
mail/src/main/java/javax/mail/FetchProfile.java
mail/src/main/java/javax/mail/Flags.java
mail/src/main/java/javax/mail/Folder.java
mail/src/main/java/javax/mail/Multipart.java
mail/src/main/java/javax/mail/Part.java
mail/src/main/java/javax/mail/Service.java
mail/src/main/java/javax/mail/Session.java
mail/src/main/java/javax/mail/Store.java
mail/src/main/java/javax/mail/Transport.java
mail/src/main/java/javax/mail/internet/InternetAddress.java
mail/src/main/java/javax/mail/internet/InternetHeaders.java
mail/src/main/java/javax/mail/internet/MimeBodyPart.java
mail/src/main/java/javax/mail/internet/MimeMessage.java
mail/src/main/java/javax/mail/internet/MimePart.java
mail/src/main/java/javax/mail/internet/MimeUtility.java
mail/src/main/java/javax/mail/internet/NewsAddress.java
mail/src/main/java/javax/mail/internet/ParameterList.java
mail/src/main/java/javax/mail/internet/PreencodedMimeBodyPart.java
mail/src/main/java/javax/mail/util/SharedFileInputStream.java
mail/src/test/java/com/sun/mail/imap/protocol/IMAPProtocolTest.java
mail/src/test/java/com/sun/mail/imap/protocol/UIDSetTest.java
mail/src/test/java/com/sun/mail/test/ClassLoaderSuite.java
mail/src/test/java/com/sun/mail/util/ContentTypeCleaner.java
mail/src/test/java/com/sun/mail/util/UUDecoderStreamTest.java
mail/src/test/java/javax/mail/internet/AllowEncodedMessages.java
mail/src/test/java/javax/mail/internet/FoldTest.java
mail/src/test/java/javax/mail/internet/HeaderTokenizerTest.java
mail/src/test/java/javax/mail/internet/InternetAddressTest.java
mail/src/test/java/javax/mail/internet/InternetHeadersTest.java
mail/src/test/java/javax/mail/internet/MailDateFormatTest.java
mail/src/test/java/javax/mail/internet/MimeBodyPartTest.java
mail/src/test/java/javax/mail/internet/MimeMessageTest.java
mail/src/test/java/javax/mail/internet/MimeMultipartPropertyTest.java
mail/src/test/java/javax/mail/internet/MimeUtilityTest.java
mail/src/test/java/javax/mail/internet/ModifyMessageTest.java
mail/src/test/java/javax/mail/internet/NonAsciiBoundaryTest.java
mail/src/test/java/javax/mail/internet/ParameterListDecode.java
mail/src/test/java/javax/mail/internet/RestrictEncodingTest.java
mail/src/main/java/javax/mail/Message.java
mail/src/main/java/javax/mail/MultipartDataSource.java
mail/src/main/java/javax/mail/Quota.java
pom.xml


Added Paths:
------------
mail/src/test/java/com/sun/mail/imap/protocol/StatusTest.java
mail/src/main/java/com/sun/mail/pop3/AppendStream.java
mail/src/main/java/com/sun/mail/pop3/WritableSharedFile.java
mail/src/test/java/com/sun/mail/test/AsciiStringInputStream.java
mail/src/test/java/com/sun/mail/test/NullOutputStream.java


Diffs:
------
diff -r a03425201934 -r 7b8854be0dfc doc/release/CHANGES.txt
--- a/doc/release/CHANGES.txt Thu Oct 15 14:58:50 2015 -0700
+++ b/doc/release/CHANGES.txt Fri Oct 16 13:59:28 2015 -0700
@@ -37,6 +37,7 @@
 K 7026 IdleManager can deadlock when not busy
 K 7027 IMAP Folder methods throw runtime exceptions when connection drops
 K 7028 InternetAddress doesn't detect some illegal newlines
+K 7030 Status class doesn't decode mailbox name
 
 
                   CHANGES IN THE 1.5.4 RELEASE

diff -r a03425201934 -r 7b8854be0dfc mail/src/main/java/com/sun/mail/imap/protocol/Status.java
--- a/mail/src/main/java/com/sun/mail/imap/protocol/Status.java Thu Oct 15 14:58:50 2015 -0700
+++ b/mail/src/main/java/com/sun/mail/imap/protocol/Status.java Fri Oct 16 13:59:28 2015 -0700
@@ -67,7 +67,8 @@
         { "MESSAGES", "RECENT", "UNSEEN", "UIDNEXT", "UIDVALIDITY" };
 
     public Status(Response r) throws ParsingException {
- mbox = r.readAtomString(); // mailbox := astring
+ // mailbox := astring
+ mbox = BASE64MailboxDecoder.decode(r.readAtomString());
 
         // Workaround buggy IMAP servers that don't quote folder names
         // with spaces.

diff -r a03425201934 -r 7b8854be0dfc mail/src/test/java/com/sun/mail/imap/protocol/StatusTest.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mail/src/test/java/com/sun/mail/imap/protocol/StatusTest.java Fri Oct 16 13:59:28 2015 -0700
@@ -0,0 +1,65 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 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 com.sun.mail.imap.protocol;
+
+import static org.junit.Assert.assertEquals;
+import org.junit.Test;
+
+/**
+ * Test the Status class.
+ */
+public class StatusTest {
+ /**
+ * Test that the returned mailbox name is decoded.
+ */
+ @Test
+ public void testMailboxDecode() throws Exception {
+ String mbox = "Entw\u00fcrfe";
+ IMAPResponse response = new IMAPResponse(
+ "* STATUS " +
+ BASE64MailboxEncoder.encode(mbox) +
+ " (MESSAGES 231 UIDNEXT 44292)");
+ Status s = new Status(response);
+ assertEquals(mbox, s.mbox);
+ assertEquals(231, s.total);
+ assertEquals(44292, s.uidnext);
+ }
+}


diff -r 7b8854be0dfc -r 062ee4a2eed1 mail/src/test/java/com/sun/mail/test/TestServer.java
--- a/mail/src/test/java/com/sun/mail/test/TestServer.java Fri Oct 16 13:59:28 2015 -0700
+++ b/mail/src/test/java/com/sun/mail/test/TestServer.java Tue Oct 20 11:16:02 2015 -0700
@@ -108,7 +108,6 @@
             } catch (IOException ex) {
                 // ignore
             }
- return;
         }
         throw new RuntimeException("Can't find unused port");
     }


diff -r 062ee4a2eed1 -r e40f71ea23ca mail/pom.xml
--- a/mail/pom.xml Tue Oct 20 11:16:02 2015 -0700
+++ b/mail/pom.xml Tue Oct 20 11:23:34 2015 -0700
@@ -157,7 +157,7 @@
         <dependency>
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>
- <version>4.7</version>
+ <version>4.12</version>
             <scope>test</scope>
             <optional>true</optional>
         </dependency>

diff -r 062ee4a2eed1 -r e40f71ea23ca mail/src/test/java/com/sun/mail/imap/IMAPAuthDebugTest.java
--- a/mail/src/test/java/com/sun/mail/imap/IMAPAuthDebugTest.java Tue Oct 20 11:16:02 2015 -0700
+++ b/mail/src/test/java/com/sun/mail/imap/IMAPAuthDebugTest.java Tue Oct 20 11:23:34 2015 -0700
@@ -67,7 +67,7 @@
 
     // timeout the test in case of deadlock
     @Rule
- public Timeout deadlockTimeout = new Timeout(20000);
+ public Timeout deadlockTimeout = Timeout.seconds(20);
 
     /**
      * Test that authentication information isn't included in the debug output.

diff -r 062ee4a2eed1 -r e40f71ea23ca mail/src/test/java/com/sun/mail/imap/IMAPIDTest.java
--- a/mail/src/test/java/com/sun/mail/imap/IMAPIDTest.java Tue Oct 20 11:16:02 2015 -0700
+++ b/mail/src/test/java/com/sun/mail/imap/IMAPIDTest.java Tue Oct 20 11:23:34 2015 -0700
@@ -63,7 +63,7 @@
 
     // timeout the test in case of deadlock
     @Rule
- public Timeout deadlockTimeout = new Timeout(20000);
+ public Timeout deadlockTimeout = Timeout.seconds(20);
 
     @Test
     public void testIDNIL() {

diff -r 062ee4a2eed1 -r e40f71ea23ca mail/src/test/java/com/sun/mail/imap/IMAPIdleManagerTest.java
--- a/mail/src/test/java/com/sun/mail/imap/IMAPIdleManagerTest.java Tue Oct 20 11:16:02 2015 -0700
+++ b/mail/src/test/java/com/sun/mail/imap/IMAPIdleManagerTest.java Tue Oct 20 11:23:34 2015 -0700
@@ -73,7 +73,7 @@
 
     // timeout the test in case of deadlock
     @Rule
- public Timeout deadlockTimeout = new Timeout(10 * TIMEOUT);
+ public Timeout deadlockTimeout = Timeout.millis(10 * TIMEOUT);
 
     /**
      * Test that IdleManager handles multiple responses in a single packet.

diff -r 062ee4a2eed1 -r e40f71ea23ca mail/src/test/java/com/sun/mail/imap/IMAPIdleStateTest.java
--- a/mail/src/test/java/com/sun/mail/imap/IMAPIdleStateTest.java Tue Oct 20 11:16:02 2015 -0700
+++ b/mail/src/test/java/com/sun/mail/imap/IMAPIdleStateTest.java Tue Oct 20 11:23:34 2015 -0700
@@ -62,7 +62,7 @@
 
     // timeout the test in case of deadlock
     @Rule
- public Timeout deadlockTimeout = new Timeout(20000);
+ public Timeout deadlockTimeout = Timeout.seconds(20);
 
     @Test
     public void test() {

diff -r 062ee4a2eed1 -r e40f71ea23ca mail/src/test/java/com/sun/mail/imap/IMAPIdleUntaggedResponseTest.java
--- a/mail/src/test/java/com/sun/mail/imap/IMAPIdleUntaggedResponseTest.java Tue Oct 20 11:16:02 2015 -0700
+++ b/mail/src/test/java/com/sun/mail/imap/IMAPIdleUntaggedResponseTest.java Tue Oct 20 11:23:34 2015 -0700
@@ -65,7 +65,7 @@
 
     // timeout the test in case of deadlock
     @Rule
- public Timeout deadlockTimeout = new Timeout(20000);
+ public Timeout deadlockTimeout = Timeout.seconds(20);
 
     @Test
     public void test() {

diff -r 062ee4a2eed1 -r e40f71ea23ca mail/src/test/java/com/sun/mail/imap/IMAPLoginReferralTest.java
--- a/mail/src/test/java/com/sun/mail/imap/IMAPLoginReferralTest.java Tue Oct 20 11:16:02 2015 -0700
+++ b/mail/src/test/java/com/sun/mail/imap/IMAPLoginReferralTest.java Tue Oct 20 11:23:34 2015 -0700
@@ -70,7 +70,7 @@
 
     // timeout the test in case of deadlock
     @Rule
- public Timeout deadlockTimeout = new Timeout(5 * TIMEOUT);
+ public Timeout deadlockTimeout = Timeout.millis(5 * TIMEOUT);
 
     /**
      * Test referral in BYE when connecting.

diff -r 062ee4a2eed1 -r e40f71ea23ca mail/src/test/java/com/sun/mail/imap/IMAPMessageNumberOutOfRangeTest.java
--- a/mail/src/test/java/com/sun/mail/imap/IMAPMessageNumberOutOfRangeTest.java Tue Oct 20 11:16:02 2015 -0700
+++ b/mail/src/test/java/com/sun/mail/imap/IMAPMessageNumberOutOfRangeTest.java Tue Oct 20 11:23:34 2015 -0700
@@ -65,7 +65,7 @@
 
     // timeout the test in case of deadlock
     @Rule
- public Timeout deadlockTimeout = new Timeout(20000);
+ public Timeout deadlockTimeout = Timeout.seconds(20);
 
     @Test
     public void test() {

diff -r 062ee4a2eed1 -r e40f71ea23ca mail/src/test/java/com/sun/mail/imap/IMAPUidExpungeTest.java
--- a/mail/src/test/java/com/sun/mail/imap/IMAPUidExpungeTest.java Tue Oct 20 11:16:02 2015 -0700
+++ b/mail/src/test/java/com/sun/mail/imap/IMAPUidExpungeTest.java Tue Oct 20 11:23:34 2015 -0700
@@ -68,7 +68,7 @@
 
     // timeout the test in case of deadlock
     @Rule
- public Timeout deadlockTimeout = new Timeout(20000);
+ public Timeout deadlockTimeout = Timeout.seconds(20);
 
     public static interface IMAPTest {
         public void test(Folder folder, IMAPHandlerExpunge handler)

diff -r 062ee4a2eed1 -r e40f71ea23ca mail/src/test/java/com/sun/mail/pop3/POP3AuthDebugTest.java
--- a/mail/src/test/java/com/sun/mail/pop3/POP3AuthDebugTest.java Tue Oct 20 11:16:02 2015 -0700
+++ b/mail/src/test/java/com/sun/mail/pop3/POP3AuthDebugTest.java Tue Oct 20 11:23:34 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
@@ -67,7 +67,7 @@
 
     // timeout the test in case of deadlock
     @Rule
- public Timeout deadlockTimeout = new Timeout(20000);
+ public Timeout deadlockTimeout = Timeout.seconds(20);
 
     /**
      * Test that authentication information isn't included in the debug output.

diff -r 062ee4a2eed1 -r e40f71ea23ca mail/src/test/java/com/sun/mail/smtp/SMTPAuthDebugTest.java
--- a/mail/src/test/java/com/sun/mail/smtp/SMTPAuthDebugTest.java Tue Oct 20 11:16:02 2015 -0700
+++ b/mail/src/test/java/com/sun/mail/smtp/SMTPAuthDebugTest.java Tue Oct 20 11:23:34 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
@@ -67,7 +67,7 @@
 
     // timeout the test in case of deadlock
     @Rule
- public Timeout deadlockTimeout = new Timeout(20000);
+ public Timeout deadlockTimeout = Timeout.seconds(20);
 
     /**
      * Test that authentication information isn't included in the debug output.

diff -r 062ee4a2eed1 -r e40f71ea23ca mail/src/test/java/com/sun/mail/smtp/SMTPCloseTest.java
--- a/mail/src/test/java/com/sun/mail/smtp/SMTPCloseTest.java Tue Oct 20 11:16:02 2015 -0700
+++ b/mail/src/test/java/com/sun/mail/smtp/SMTPCloseTest.java Tue Oct 20 11:23:34 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
@@ -59,7 +59,7 @@
 
     // timeout the test in case of failure
     @Rule
- public Timeout deadlockTimeout = new Timeout(5000);
+ public Timeout deadlockTimeout = Timeout.seconds(5);
 
     @Test
     public void test() {

diff -r 062ee4a2eed1 -r e40f71ea23ca mail/src/test/java/com/sun/mail/smtp/SMTPIOExceptionTest.java
--- a/mail/src/test/java/com/sun/mail/smtp/SMTPIOExceptionTest.java Tue Oct 20 11:16:02 2015 -0700
+++ b/mail/src/test/java/com/sun/mail/smtp/SMTPIOExceptionTest.java Tue Oct 20 11:23:34 2015 -0700
@@ -67,7 +67,7 @@
 
     // timeout the test in case of failure
     @Rule
- public Timeout deadlockTimeout = new Timeout(5000);
+ public Timeout deadlockTimeout = Timeout.seconds(5);
 
     private boolean closed = false;
 

diff -r 062ee4a2eed1 -r e40f71ea23ca mail/src/test/java/com/sun/mail/smtp/SMTPWriteTimeoutTest.java
--- a/mail/src/test/java/com/sun/mail/smtp/SMTPWriteTimeoutTest.java Tue Oct 20 11:16:02 2015 -0700
+++ b/mail/src/test/java/com/sun/mail/smtp/SMTPWriteTimeoutTest.java Tue Oct 20 11:23:34 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
@@ -66,7 +66,7 @@
 
     // timeout the test in case of failure
     @Rule
- public Timeout deadlockTimeout = new Timeout(5000);
+ public Timeout deadlockTimeout = Timeout.seconds(5);
 
     private static final int TIMEOUT = 200; // write timeout, in millis
 

diff -r 062ee4a2eed1 -r e40f71ea23ca mail/src/test/java/com/sun/mail/util/WriteTimeoutSocketTest.java
--- a/mail/src/test/java/com/sun/mail/util/WriteTimeoutSocketTest.java Tue Oct 20 11:16:02 2015 -0700
+++ b/mail/src/test/java/com/sun/mail/util/WriteTimeoutSocketTest.java Tue Oct 20 11:23:34 2015 -0700
@@ -70,7 +70,7 @@
 
     // timeout the test in case of deadlock
     @Rule
- public Timeout deadlockTimeout = new Timeout(20000);
+ public Timeout deadlockTimeout = Timeout.seconds(20);
 
     private static final int TIMEOUT = 200; // ms
     private static final String data =

diff -r 062ee4a2eed1 -r e40f71ea23ca mail/src/test/java/com/sun/mail/util/logging/LogManagerPropertiesTest.java
--- a/mail/src/test/java/com/sun/mail/util/logging/LogManagerPropertiesTest.java Tue Oct 20 11:16:02 2015 -0700
+++ b/mail/src/test/java/com/sun/mail/util/logging/LogManagerPropertiesTest.java Tue Oct 20 11:23:34 2015 -0700
@@ -52,7 +52,6 @@
 import java.util.logging.*;
 import javax.mail.*;
 import javax.mail.internet.InternetAddress;
-import junit.framework.Assert;
 import org.junit.*;
 import static org.junit.Assert.*;
 


diff -r e40f71ea23ca -r 5d0dac7b71d2 doc/release/CHANGES.txt
--- a/doc/release/CHANGES.txt Tue Oct 20 11:23:34 2015 -0700
+++ b/doc/release/CHANGES.txt Tue Oct 20 12:39:10 2015 -0700
@@ -38,6 +38,7 @@
 K 7027 IMAP Folder methods throw runtime exceptions when connection drops
 K 7028 InternetAddress doesn't detect some illegal newlines
 K 7030 Status class doesn't decode mailbox name
+K 7035 add support for IMAP COMPRESS extension (RFC 4978)
 
 
                   CHANGES IN THE 1.5.4 RELEASE

diff -r e40f71ea23ca -r 5d0dac7b71d2 mail/src/main/java/com/sun/mail/iap/Protocol.java
--- a/mail/src/main/java/com/sun/mail/iap/Protocol.java Tue Oct 20 11:23:34 2015 -0700
+++ b/mail/src/main/java/com/sun/mail/iap/Protocol.java Tue Oct 20 12:39:10 2015 -0700
@@ -47,6 +47,11 @@
 import java.net.*;
 import java.util.logging.Level;
 import javax.net.ssl.SSLSocket;
+import java.util.zip.Deflater;
+import java.util.zip.DeflaterOutputStream;
+import java.util.zip.Inflater;
+import java.util.zip.InflaterInputStream;
+
 import com.sun.mail.util.*;
 
 /**
@@ -446,6 +451,53 @@
     }
 
     /**
+ * Start compression on the current connection.
+ * <code>cmd</code> is the command to issue to start compression.
+ * If the command succeeds, we begin compression.
+ *
+ * @param cmd the command to issue
+ * @exception IOException for I/O errors
+ * @exception ProtocolException for protocol failures
+ */
+ public synchronized void startCompression(String cmd)
+ throws IOException, ProtocolException {
+ // XXX - check whether compression is already enabled?
+ simpleCommand(cmd, null);
+ // need to create our own Inflater and Deflater in order to set nowrap
+ Inflater inf = new Inflater(true);
+ traceInput = new TraceInputStream(new InflaterInputStream(
+ socket.getInputStream(), inf), traceLogger);
+ traceInput.setQuote(quote);
+ input = new ResponseInputStream(traceInput);
+
+ // configure the Deflater
+ int level = PropUtil.getIntProperty(props, prefix + ".compress.level",
+ Deflater.DEFAULT_COMPRESSION);
+ int strategy = PropUtil.getIntProperty(props,
+ prefix + ".compress.strategy",
+ Deflater.DEFAULT_STRATEGY);
+ if (logger.isLoggable(Level.FINE))
+ logger.log(Level.FINE,
+ "Creating Deflater with compression level {0} and strategy {1}",
+ new Object[] { level, strategy });
+ Deflater def = new Deflater(Deflater.DEFAULT_COMPRESSION, true);
+ try {
+ def.setLevel(level);
+ } catch (IllegalArgumentException ex) {
+ logger.log(Level.FINE, "Ignoring bad compression level", ex);
+ }
+ try {
+ def.setStrategy(strategy);
+ } catch (IllegalArgumentException ex) {
+ logger.log(Level.FINE, "Ignoring bad compression strategy", ex);
+ }
+ traceOutput = new TraceOutputStream(new DeflaterOutputStream(
+ socket.getOutputStream(), def, true), traceLogger);
+ traceOutput.setQuote(quote);
+ output = new DataOutputStream(new BufferedOutputStream(traceOutput));
+ }
+
+ /**
      * Is this connection using an SSL socket?
      *
      * @return true if using SSL

diff -r e40f71ea23ca -r 5d0dac7b71d2 mail/src/main/java/com/sun/mail/imap/IMAPStore.java
--- a/mail/src/main/java/com/sun/mail/imap/IMAPStore.java Tue Oct 20 11:23:34 2015 -0700
+++ b/mail/src/main/java/com/sun/mail/imap/IMAPStore.java Tue Oct 20 12:39:10 2015 -0700
@@ -223,6 +223,7 @@
     private boolean throwSearchException = false;
     private boolean peek = false;
     private boolean closeFoldersOnStoreFailure = true;
+ private boolean enableCompress = false; // enable COMPRESS=DEFLATE
 
     /*
      * This field is set in the Store's response handler if we see
@@ -589,6 +590,12 @@
         if (closeFoldersOnStoreFailure)
             logger.config("closeFoldersOnStoreFailure");
 
+ // check if COMPRESS is enabled
+ enableCompress = PropUtil.getBooleanSessionProperty(session,
+ "mail." + name + ".compress.enable", false);
+ if (enableCompress)
+ logger.config("enable COMPRESS");
+
         s = session.getProperty("mail." + name + ".folder.class");
         if (s != null) {
             logger.log(Level.CONFIG, "IMAP: folder class: {0}", s);
@@ -816,6 +823,12 @@
                 // ignore other exceptions that "should never happen"
             }
         }
+
+ if (enableCompress) {
+ if (p.hasCapability("COMPRESS=DEFLATE")) {
+ p.compress();
+ }
+ }
     }
 
     /**

diff -r e40f71ea23ca -r 5d0dac7b71d2 mail/src/main/java/com/sun/mail/imap/package.html
--- a/mail/src/main/java/com/sun/mail/imap/package.html Tue Oct 20 11:23:34 2015 -0700
+++ b/mail/src/main/java/com/sun/mail/imap/package.html Tue Oct 20 12:39:10 2015 -0700
@@ -218,6 +218,14 @@
 A referral can also occur when login succeeds. By default, no exception is
 thrown in this case. To force an exception to be thrown and the authentication
 to fail, set the <code>mail.imap.referralexception</code> property to "true".
+<H4>COMPRESS Support</H4>
+<P>
+The IMAP COMPRESS extension
+(<A HREF="http://www.ietf.org/rfc/rfc4978.txt" TARGET="_top">RFC 4978</A>)
+is supported.
+If the server supports the extension and the
+<code>mail.imap.compress.enable</code> property is set to "true",
+compression will be enabled.
 <H4>Properties</H4>
 <P>
 The IMAP protocol provider supports the following properties,
@@ -806,13 +814,41 @@
 <TD>mail.imap.referralexception</TD>
 <TD>boolean</TD>
 <TD>
-If set to true and an IMAP login referral is returned when the autnetication
+If set to true and an IMAP login referral is returned when the authentication
 succeeds, fail the connect request and throw a
 {_at_link com.sun.mail.imap.ReferralException ReferralException}.
 Defaults to false.
 </TD>
 </TR>
 
+<TR>
+<TD>mail.imap.compress.enable</TD>
+<TD>boolean</TD>
+<TD>
+If set to true and the IMAP server supports the COMPRESS=DEFLATE extension,
+compression will be enabled.
+Defaults to false.
+</TD>
+</TR>
+
+<TR>
+<TD>mail.imap.compress.level</TD>
+<TD>int</TD>
+<TD>
+The compression level to be used, in the range -1 to 9.
+See the {_at_link java.util.zip.Deflater Deflater} class for details.
+</TD>
+</TR>
+
+<TR>
+<TD>mail.imap.compress.strategy</TD>
+<TD>int</TD>
+<TD>
+The compression strategy to be used, in the range 0 to 2.
+See the {_at_link java.util.zip.Deflater Deflater} class for details.
+</TD>
+</TR>
+
 </TABLE>
 <P>
 In general, applications should not need to use the classes in this

diff -r e40f71ea23ca -r 5d0dac7b71d2 mail/src/main/java/com/sun/mail/imap/protocol/IMAPProtocol.java
--- a/mail/src/main/java/com/sun/mail/imap/protocol/IMAPProtocol.java Tue Oct 20 11:23:34 2015 -0700
+++ b/mail/src/main/java/com/sun/mail/imap/protocol/IMAPProtocol.java Tue Oct 20 12:39:10 2015 -0700
@@ -1095,6 +1095,32 @@
     }
 
     /**
+ * COMPRESS Command. Only supports DEFLATE.
+ *
+ * @exception ProtocolException for protocol failures
+ * @see "RFC 4978"
+ */
+ public void compress() throws ProtocolException {
+ try {
+ super.startCompression("COMPRESS DEFLATE");
+ } catch (ProtocolException pex) {
+ logger.log(Level.FINE, "COMPRESS ProtocolException", pex);
+ // ProtocolException just means the command wasn't recognized,
+ // or failed. This should never happen if we check the
+ // CAPABILITY first.
+ throw pex;
+ } catch (Exception ex) {
+ logger.log(Level.FINE, "COMPRESS Exception", ex);
+ // any other exception means we have to shut down the connection
+ // generate an artificial BYE response and disconnect
+ Response[] r = { Response.byeResponse(ex) };
+ notifyResponseHandlers(r);
+ disconnect();
+ throw new ProtocolException("COMPRESS failure", ex);
+ }
+ }
+
+ /**
      * SELECT Command.
      *
      * @param mbox the mailbox name


diff -r 5d0dac7b71d2 -r 88dfebaed1fa mail/pom.xml
--- a/mail/pom.xml Tue Oct 20 12:39:10 2015 -0700
+++ b/mail/pom.xml Wed Oct 21 09:11:35 2015 +0200
@@ -102,34 +102,19 @@
             -->
             <plugin>
                 <artifactId>maven-compiler-plugin</artifactId>
- <executions>
- <execution>
- <id>default-compile</id>
- <configuration>
- <source>1.5</source>
- <target>1.5</target>
- <fork>true</fork>
- <!--
- ignore some of the errors that are
- too hard to fix for now
- -->
- <compilerArguments>
- <Xlint:all/>
- <Xlint:-rawtypes/>
- <Xlint:-unchecked/>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ <compilerArguments>
+ <Xlint/>
+ <!-- 1.5 is obsolete and will be removed in a future release -->
+ <Xlint:-options/>
                                 <Xlint:-finally/>
- </compilerArguments>
- <showWarnings>true</showWarnings>
- </configuration>
- </execution>
- <execution>
- <id>default-testCompile</id>
- <configuration>
- <source>1.5</source>
- <target>1.5</target>
- </configuration>
- </execution>
- </executions>
+ <Werror/>
+ </compilerArguments>
+ <showDeprecation>true</showDeprecation>
+ <showWarnings>true</showWarnings>
+ </configuration>
             </plugin>
 
             <!--

diff -r 5d0dac7b71d2 -r 88dfebaed1fa mail/src/main/java/com/sun/mail/iap/Argument.java
--- a/mail/src/main/java/com/sun/mail/iap/Argument.java Tue Oct 20 12:39:10 2015 -0700
+++ b/mail/src/main/java/com/sun/mail/iap/Argument.java Wed Oct 21 09:11:35 2015 +0200
@@ -51,13 +51,13 @@
  */
 
 public class Argument {
- protected List items;
+ protected List<Object> items;
 
     /**
      * Constructor
      */
     public Argument() {
- items = new ArrayList(1);
+ items = new ArrayList<Object>(1);
     }
 
     /**

diff -r 5d0dac7b71d2 -r 88dfebaed1fa mail/src/main/java/com/sun/mail/iap/Protocol.java
--- a/mail/src/main/java/com/sun/mail/iap/Protocol.java Tue Oct 20 12:39:10 2015 -0700
+++ b/mail/src/main/java/com/sun/mail/iap/Protocol.java Wed Oct 21 09:11:35 2015 +0200
@@ -89,7 +89,8 @@
      * because we depend on it always existing and depend
      * on the synchronization that Vector provides.
      */
- private final Vector handlers = new Vector(); // response handlers
+ private final Vector<ResponseHandler> handlers
+ = new Vector<ResponseHandler>(); // response handlers
 
     private volatile long timestamp;
 
@@ -339,7 +340,7 @@
      */
     public synchronized Response[] command(String command, Argument args) {
         commandStart(command);
- Vector v = new Vector();
+ Vector<Response> v = new Vector<Response>();
         boolean done = false;
         String tag = null;
         Response r = null;

diff -r 5d0dac7b71d2 -r 88dfebaed1fa mail/src/main/java/com/sun/mail/iap/Response.java
--- a/mail/src/main/java/com/sun/mail/iap/Response.java Tue Oct 20 12:39:10 2015 -0700
+++ b/mail/src/main/java/com/sun/mail/iap/Response.java Wed Oct 21 09:11:35 2015 +0200
@@ -286,7 +286,7 @@
             return null;
         index++; // skip '('
 
- Vector v = new Vector();
+ Vector<String> v = new Vector<String>();
         do {
             v.addElement(atom ? readAtomString() : readString());
         } while (buffer[index++] != ')');

diff -r 5d0dac7b71d2 -r 88dfebaed1fa mail/src/main/java/com/sun/mail/imap/IMAPBodyPart.java
--- a/mail/src/main/java/com/sun/mail/imap/IMAPBodyPart.java Tue Oct 20 12:39:10 2015 -0700
+++ b/mail/src/main/java/com/sun/mail/imap/IMAPBodyPart.java Wed Oct 21 09:11:35 2015 +0200
@@ -243,9 +243,11 @@
 
                     try {
                         // Write out the header
- Enumeration hdrLines = super.getAllHeaderLines();
+ @SuppressWarnings("unchecked")
+ Enumeration<String> hdrLines
+ = super.getAllHeaderLines();
                         while (hdrLines.hasMoreElements())
- los.writeln((String)hdrLines.nextElement());
+ los.writeln(hdrLines.nextElement());
 
                         // The CRLF separator between header and content
                         los.writeln();
@@ -334,18 +336,21 @@
         throw new IllegalWriteException("IMAPBodyPart is read-only");
     }
 
- public Enumeration getAllHeaders() throws MessagingException {
+ @SuppressWarnings("unchecked")
+ public Enumeration<Header> getAllHeaders() throws MessagingException {
         loadHeaders();
         return super.getAllHeaders();
     }
 
- public Enumeration getMatchingHeaders(String[] names)
+ @SuppressWarnings("unchecked")
+ public Enumeration<Header> getMatchingHeaders(String[] names)
                 throws MessagingException {
         loadHeaders();
         return super.getMatchingHeaders(names);
     }
 
- public Enumeration getNonMatchingHeaders(String[] names)
+ @SuppressWarnings("unchecked")
+ public Enumeration<Header> getNonMatchingHeaders(String[] names)
                 throws MessagingException {
         loadHeaders();
         return super.getNonMatchingHeaders(names);
@@ -355,18 +360,21 @@
         throw new IllegalWriteException("IMAPBodyPart is read-only");
     }
 
- public Enumeration getAllHeaderLines() throws MessagingException {
+ @SuppressWarnings("unchecked")
+ public Enumeration<String> getAllHeaderLines() throws MessagingException {
         loadHeaders();
         return super.getAllHeaderLines();
     }
 
- public Enumeration getMatchingHeaderLines(String[] names)
+ @SuppressWarnings("unchecked")
+ public Enumeration<String> getMatchingHeaderLines(String[] names)
                 throws MessagingException {
         loadHeaders();
         return super.getMatchingHeaderLines(names);
     }
 
- public Enumeration getNonMatchingHeaderLines(String[] names)
+ @SuppressWarnings("unchecked")
+ public Enumeration<String> getNonMatchingHeaderLines(String[] names)
                 throws MessagingException {
         loadHeaders();
         return super.getNonMatchingHeaderLines(names);

diff -r 5d0dac7b71d2 -r 88dfebaed1fa mail/src/main/java/com/sun/mail/imap/IMAPFolder.java
--- a/mail/src/main/java/com/sun/mail/imap/IMAPFolder.java Tue Oct 20 12:39:10 2015 -0700
+++ b/mail/src/main/java/com/sun/mail/imap/IMAPFolder.java Wed Oct 21 09:11:35 2015 +0200
@@ -192,7 +192,7 @@
     // accessor lock for message cache
     protected final Object messageCacheLock = new Object();
 
- protected Hashtable uidTable; // UID->Message hashtable
+ protected Hashtable<Long, IMAPMessage> uidTable; // UID->Message hashtable
 
     /* An IMAP delimiter is a 7bit US-ASCII character. (except NUL).
      * We use '\uffff' (a non 7bit character) to indicate that we havent
@@ -1222,8 +1222,8 @@
                 return;
 
             Response[] r = null;
- Vector v = new Vector(); // to collect non-FETCH responses &
- // unsolicited FETCH FLAG responses
+ // to collect non-FETCH responses & unsolicited FETCH FLAG responses
+ Vector<Response> v = new Vector<Response>();
             try {
                 r = getProtocol().fetch(msgsets, command.toString());
             } catch (ConnectionException cex) {
@@ -2501,11 +2501,11 @@
 
                 if (uidTable != null) {
                     // Check in uidTable
- m = (IMAPMessage)uidTable.get(l);
+ m = uidTable.get(l);
                     if (m != null) // found it
                         return m;
                 } else
- uidTable = new Hashtable();
+ uidTable = new Hashtable<Long, IMAPMessage>();
 
                 // Check with the server
                 // Issue UID FETCH command
@@ -2513,7 +2513,7 @@
 
                 if (uidTable != null) {
                     // Check in uidTable
- m = (IMAPMessage)uidTable.get(l);
+ m = uidTable.get(l);
                     if (m != null) // found it
                         return m;
                 }
@@ -2541,7 +2541,7 @@
         try {
             synchronized(messageCacheLock) {
                 if (uidTable == null)
- uidTable = new Hashtable();
+ uidTable = new Hashtable<Long, IMAPMessage>();
 
                 // Issue UID FETCH for given range
                 long[] ua = getProtocol().fetchSequenceNumbers(start, end);
@@ -2549,7 +2549,7 @@
                 List<Message> ma = new ArrayList<Message>();
                 // NOTE: Below must be within messageCacheLock region
                 for (int i = 0; i < ua.length; i++) {
- Message m = (Message)uidTable.get(Long.valueOf(ua[i]));
+ Message m = uidTable.get(Long.valueOf(ua[i]));
                     if (m != null) // found it
                         ma.add(m);
                 }
@@ -2579,7 +2579,8 @@
             synchronized(messageCacheLock) {
                 long[] unavailUids = uids;
                 if (uidTable != null) {
- Vector v = new Vector(); // to collect unavailable UIDs
+ // to collect unavailable UIDs
+ Vector<Long> v = new Vector<Long>();
                     Long l;
                     for (int i = 0; i < uids.length; i++) {
                         if (!uidTable.containsKey(l = Long.valueOf(uids[i])))
@@ -2590,9 +2591,9 @@
                     int vsize = v.size();
                     unavailUids = new long[vsize];
                     for (int i = 0; i < vsize; i++)
- unavailUids[i] = ((Long)v.elementAt(i)).longValue();
+ unavailUids[i] = v.elementAt(i).longValue();
                 } else
- uidTable = new Hashtable();
+ uidTable = new Hashtable<Long, IMAPMessage>();
 
                 if (unavailUids.length > 0) {
                     // Issue UID FETCH request for given uids
@@ -2643,7 +2644,7 @@
 
                     // insert this message into uidTable
                     if (uidTable == null)
- uidTable = new Hashtable();
+ uidTable = new Hashtable<Long, IMAPMessage>();
                     uidTable.put(Long.valueOf(uid), m);
                 }
             } catch (ConnectionException cex) {
@@ -2664,7 +2665,7 @@
         for (int i = 0; i < uids.length; i++) {
             IMAPMessage m = null;
             if (uidTable != null)
- m = (IMAPMessage)uidTable.get(Long.valueOf(uids[i]));
+ m = uidTable.get(Long.valueOf(uids[i]));
             if (m == null) {
                 // fake it, we don't know what message this really is
                 m = newIMAPMessage(-1); // no sequence number
@@ -3279,6 +3280,7 @@
      * ID extension
      * @since JavaMail 1.5.1
      */
+ @SuppressWarnings("unchecked")
     public Map<String, String> id(final Map<String, String> clientParams)
                                 throws MessagingException {
         checkOpened();
@@ -3479,7 +3481,7 @@
             if (uid != null && msg.getUID() != uid.uid) {
                 msg.setUID(uid.uid);
                 if (uidTable == null)
- uidTable = new Hashtable();
+ uidTable = new Hashtable<Long, IMAPMessage>();
                 uidTable.put(Long.valueOf(uid.uid), msg);
                 notify = true;
             }

diff -r 5d0dac7b71d2 -r 88dfebaed1fa mail/src/main/java/com/sun/mail/imap/IMAPMessage.java
--- a/mail/src/main/java/com/sun/mail/imap/IMAPMessage.java Tue Oct 20 12:39:10 2015 -0700
+++ b/mail/src/main/java/com/sun/mail/imap/IMAPMessage.java Wed Oct 21 09:11:35 2015 +0200
@@ -88,7 +88,7 @@
      *
      * @since JavaMail 1.4.6
      */
- protected Map items; // Map<String,Object>
+ protected Map<String, Object> items; // Map<String,Object>
 
     private Date receivedDate; // INTERNALDATE
     private int size = -1; // RFC822.SIZE
@@ -124,7 +124,8 @@
      *
      * Could this somehow be included in the InternetHeaders object ??
      */
- private Hashtable loadedHeaders = new Hashtable(1);
+ private Hashtable<String, String> loadedHeaders
+ = new Hashtable<String, String>(1);
 
     // This is our Envelope
     static final String EnvelopeCmd = "ENVELOPE INTERNALDATE RFC822.SIZE";
@@ -937,7 +938,8 @@
     /**
      * Get all headers.
      */
- public Enumeration getAllHeaders() throws MessagingException {
+ @SuppressWarnings("unchecked")
+ public Enumeration<Header> getAllHeaders() throws MessagingException {
         checkExpunged();
         loadHeaders();
         return super.getAllHeaders();
@@ -946,7 +948,8 @@
     /**
      * Get matching headers.
      */
- public Enumeration getMatchingHeaders(String[] names)
+ @SuppressWarnings("unchecked")
+ public Enumeration<Header> getMatchingHeaders(String[] names)
                         throws MessagingException {
         checkExpunged();
         loadHeaders();
@@ -956,7 +959,8 @@
     /**
      * Get non-matching headers.
      */
- public Enumeration getNonMatchingHeaders(String[] names)
+ @SuppressWarnings("unchecked")
+ public Enumeration<Header> getNonMatchingHeaders(String[] names)
                         throws MessagingException {
         checkExpunged();
         loadHeaders();
@@ -970,7 +974,8 @@
     /**
      * Get all header-lines.
      */
- public Enumeration getAllHeaderLines() throws MessagingException {
+ @SuppressWarnings("unchecked")
+ public Enumeration<String> getAllHeaderLines() throws MessagingException {
         checkExpunged();
         loadHeaders();
         return super.getAllHeaderLines();
@@ -979,7 +984,8 @@
     /**
      * Get all matching header-lines.
      */
- public Enumeration getMatchingHeaderLines(String[] names)
+ @SuppressWarnings("unchecked")
+ public Enumeration<String> getMatchingHeaderLines(String[] names)
                         throws MessagingException {
         checkExpunged();
         loadHeaders();
@@ -989,7 +995,8 @@
     /**
      * Get all non-matching headerlines.
      */
- public Enumeration getNonMatchingHeaderLines(String[] names)
+ @SuppressWarnings("unchecked")
+ public Enumeration<String> getNonMatchingHeaderLines(String[] names)
                         throws MessagingException {
         checkExpunged();
         loadHeaders();
@@ -1100,7 +1107,7 @@
         private boolean needSize = false;
         private boolean needMessage = false;
         private String[] hdrs = null;
- private Set need = new HashSet(); // Set<FetchItem>
+ private Set<FetchItem> need = new HashSet<FetchItem>();
 
         /**
          * Create a FetchProfileCondition to determine if we need to fetch
@@ -1160,9 +1167,9 @@
                 if (!m.isHeaderLoaded(hdrs[i]))
                     return true; // Nope, return
             }
- Iterator it = need.iterator();
+ Iterator<FetchItem> it = need.iterator();
             while (it.hasNext()) {
- FetchItem fitem = (FetchItem)it.next();
+ FetchItem fitem = it.next();
                 if (m.items == null || m.items.get(fitem.getName()) == null)
                     return true;
             }
@@ -1208,7 +1215,8 @@
             uid = u.uid; // set uid
             // add entry into uid table
             if (((IMAPFolder)folder).uidTable == null)
- ((IMAPFolder)folder).uidTable = new Hashtable();
+ ((IMAPFolder) folder).uidTable
+ = new Hashtable<Long, IMAPMessage>();
             ((IMAPFolder)folder).uidTable.put(Long.valueOf(u.uid), this);
         }
 
@@ -1264,9 +1272,10 @@
                      * object, because InternetHeaders is not thread
                      * safe.
                      */
- Enumeration e = h.getAllHeaders();
+ @SuppressWarnings("unchecked")
+ Enumeration<Header> e = h.getAllHeaders();
                     while (e.hasMoreElements()) {
- Header he = (Header)e.nextElement();
+ Header he = e.nextElement();
                         if (!isHeaderLoaded(he.getName()))
                             headers.addHeader(
                                         he.getName(), he.getValue());
@@ -1298,11 +1307,12 @@
      * @param extensionItems the Map to add fetch items to
      * @since JavaMail 1.4.6
      */
- protected void handleExtensionFetchItems(Map extensionItems) {
+ protected void handleExtensionFetchItems(
+ Map<String, Object> extensionItems) {
         if (extensionItems == null || extensionItems.isEmpty())
             return;
         if (items == null)
- items = new HashMap();
+ items = new HashMap<String, Object>();
         items.putAll(extensionItems);
     }
 

diff -r 5d0dac7b71d2 -r 88dfebaed1fa mail/src/main/java/com/sun/mail/imap/IMAPMultipartDataSource.java
--- a/mail/src/main/java/com/sun/mail/imap/IMAPMultipartDataSource.java Tue Oct 20 12:39:10 2015 -0700
+++ b/mail/src/main/java/com/sun/mail/imap/IMAPMultipartDataSource.java Wed Oct 21 09:11:35 2015 +0200
@@ -59,13 +59,13 @@
 
 public class IMAPMultipartDataSource extends MimePartDataSource
                                      implements MultipartDataSource {
- private Vector parts;
+ private Vector<IMAPBodyPart> parts;
 
     protected IMAPMultipartDataSource(MimePart part, BODYSTRUCTURE[] bs,
                                       String sectionId, IMAPMessage msg) {
         super(part);
 
- parts = new Vector(bs.length);
+ parts = new Vector<IMAPBodyPart>(bs.length);
         for (int i = 0; i < bs.length; i++)
             parts.addElement(
                 new IMAPBodyPart(bs[i],
@@ -81,6 +81,6 @@
     }
 
     public BodyPart getBodyPart(int index) throws MessagingException {
- return (BodyPart)parts.elementAt(index);
+ return parts.elementAt(index);
     }
 }

diff -r 5d0dac7b71d2 -r 88dfebaed1fa mail/src/main/java/com/sun/mail/imap/IMAPStore.java
--- a/mail/src/main/java/com/sun/mail/imap/IMAPStore.java Tue Oct 20 12:39:10 2015 -0700
+++ b/mail/src/main/java/com/sun/mail/imap/IMAPStore.java Wed Oct 21 09:11:35 2015 +0200
@@ -245,18 +245,19 @@
     private boolean messageCacheDebug;
 
     // constructors for IMAPFolder class provided by user
- private volatile Constructor folderConstructor = null;
- private volatile Constructor folderConstructorLI = null;
+ private volatile Constructor<?> folderConstructor = null;
+ private volatile Constructor<?> folderConstructorLI = null;
 
     // Connection pool info
 
     static class ConnectionPool {
 
         // container for the pool's IMAP protocol objects
- private Vector authenticatedConnections = new Vector();
+ private Vector<IMAPProtocol> authenticatedConnections
+ = new Vector<IMAPProtocol>();
 
         // vectore of open folders
- private Vector folders;
+ private Vector<IMAPFolder> folders;
 
         // is the store connection being used?
         private boolean storeConnectionInUse = false;
@@ -519,7 +520,7 @@
             if (s != null && s.length() > 0) {
                 if (logger.isLoggable(Level.CONFIG))
                     logger.config("SASL mechanisms allowed: " + s);
- Vector v = new Vector(5);
+ Vector<String> v = new Vector<String>(5);
                 StringTokenizer st = new StringTokenizer(s, " ,");
                 while (st.hasMoreTokens()) {
                     String m = st.nextToken();
@@ -603,7 +604,7 @@
                 ClassLoader cl = this.getClass().getClassLoader();
 
                 // now load the class
- Class folderClass = null;
+ Class<?> folderClass = null;
                 try {
                     // First try the "application's" class loader.
                     // This should eventually be replaced by
@@ -616,10 +617,10 @@
                     folderClass = Class.forName(s);
                 }
 
- Class[] c = { String.class, char.class, IMAPStore.class,
+ Class<?>[] c = { String.class, char.class, IMAPStore.class,
                                 Boolean.class };
                 folderConstructor = folderClass.getConstructor(c);
- Class[] c2 = { ListInfo.class, IMAPStore.class };
+ Class<?>[] c2 = { ListInfo.class, IMAPStore.class };
                 folderConstructorLI = folderClass.getConstructor(c2);
             } catch (Exception ex) {
                 logger.log(Level.CONFIG,
@@ -1025,7 +1026,7 @@
                         pool.authenticatedConnections.size());
 
                 // remove the available connection from the Authenticated queue
- p = (IMAPProtocol)pool.authenticatedConnections.lastElement();
+ p = pool.authenticatedConnections.lastElement();
                 pool.authenticatedConnections.removeElement(p);
 
                 // check if the connection is still live
@@ -1092,7 +1093,7 @@
             // Add folder to folder-list
             if (folder != null) {
                 if (pool.folders == null)
- pool.folders = new Vector();
+ pool.folders = new Vector<IMAPFolder>();
                 pool.folders.addElement(folder);
             }
         }
@@ -1160,7 +1161,7 @@
                     pool.logger.fine("getStoreProtocol() - " +
                         "connection available -- size: " +
                         pool.authenticatedConnections.size());
- p = (IMAPProtocol)pool.authenticatedConnections.firstElement();
+ p = pool.authenticatedConnections.firstElement();
 
                 // if proxyAuthUser has changed, switch to new user
                 if (proxyAuthUser != null &&
@@ -1384,7 +1385,7 @@
             for (int index = pool.authenticatedConnections.size() - 1;
                     index >= 0; --index) {
                 try {
- IMAPProtocol p = (IMAPProtocol)
+ IMAPProtocol p =
                         pool.authenticatedConnections.elementAt(index);
                     p.removeResponseHandler(this);
                     if (force)
@@ -1427,7 +1428,7 @@
                 // (leave the first connection).
                 for (int index = pool.authenticatedConnections.size() - 1;
                      index > 0; index--) {
- p = (IMAPProtocol)pool.authenticatedConnections.
+ p = pool.authenticatedConnections.
                         elementAt(index);
                     if (pool.logger.isLoggable(Level.FINE))
                         pool.logger.fine("protocol last used: " +
@@ -1693,7 +1694,7 @@
             logger.fine("IMAPStore cleanup, force " + force);
 
         if (!force || closeFoldersOnStoreFailure) {
- Vector foldersCopy = null;
+ Vector<IMAPFolder> foldersCopy = null;
         boolean done = true;
 
         // To avoid violating the locking hierarchy, there's no lock we
@@ -1720,7 +1721,7 @@
 
             // Close and remove any open folders under this Store.
             for (int i = 0, fsize = foldersCopy.size(); i < fsize; i++) {
- IMAPFolder f = (IMAPFolder)foldersCopy.elementAt(i);
+ IMAPFolder f = foldersCopy.elementAt(i);
 
                 try {
                     if (force) {

diff -r 5d0dac7b71d2 -r 88dfebaed1fa mail/src/main/java/com/sun/mail/imap/MessageCache.java
--- a/mail/src/main/java/com/sun/mail/imap/MessageCache.java Tue Oct 20 12:39:10 2015 -0700
+++ b/mail/src/main/java/com/sun/mail/imap/MessageCache.java Wed Oct 21 09:11:35 2015 +0200
@@ -216,7 +216,8 @@
      */
     public IMAPMessage[] removeExpungedMessages() {
         logger.fine("remove expunged messages");
- List mlist = new ArrayList(); // list of expunged messages
+ // list of expunged messages
+ List<IMAPMessage> mlist = new ArrayList<IMAPMessage>();
 
         /*
          * Walk through the array compressing it by copying
@@ -266,7 +267,8 @@
      */
     public IMAPMessage[] removeExpungedMessages(Message[] msgs) {
         logger.fine("remove expunged messages");
- List mlist = new ArrayList(); // list of expunged messages
+ // list of expunged messages
+ List<IMAPMessage> mlist = new ArrayList<IMAPMessage>();
 
         /*
          * Copy the message numbers of the expunged messages into

diff -r 5d0dac7b71d2 -r 88dfebaed1fa mail/src/main/java/com/sun/mail/imap/Rights.java
--- a/mail/src/main/java/com/sun/mail/imap/Rights.java Tue Oct 20 12:39:10 2015 -0700
+++ b/mail/src/main/java/com/sun/mail/imap/Rights.java Wed Oct 21 09:11:35 2015 +0200
@@ -305,7 +305,7 @@
      * @return array of Rights.Right objects representing rights
      */
     public Right[] getRights() {
- Vector v = new Vector();
+ Vector<Right> v = new Vector<Right>();
         for (int i = 0; i < this.rights.length; i++)
             if (this.rights[i])
                 v.addElement(Right.getInstance((char)i));

diff -r 5d0dac7b71d2 -r 88dfebaed1fa mail/src/main/java/com/sun/mail/imap/Utility.java
--- a/mail/src/main/java/com/sun/mail/imap/Utility.java Tue Oct 20 12:39:10 2015 -0700
+++ b/mail/src/main/java/com/sun/mail/imap/Utility.java Wed Oct 21 09:11:35 2015 +0200
@@ -77,7 +77,7 @@
      * @return the MessageSet array
      */
     public static MessageSet[] toMessageSet(Message[] msgs, Condition cond) {
- Vector v = new Vector(1);
+ Vector<MessageSet> v = new Vector<MessageSet>(1);
         int current, next;
 
         IMAPMessage msg;
@@ -172,7 +172,7 @@
      * @return the UIDSet array
      */
     public static UIDSet[] toUIDSet(Message[] msgs) {
- Vector v = new Vector(1);
+ Vector<UIDSet> v = new Vector<UIDSet>(1);
         long current, next;
 
         IMAPMessage msg;

diff -r 5d0dac7b71d2 -r 88dfebaed1fa mail/src/main/java/com/sun/mail/imap/protocol/FetchResponse.java
--- a/mail/src/main/java/com/sun/mail/imap/protocol/FetchResponse.java Tue Oct 20 12:39:10 2015 -0700
+++ b/mail/src/main/java/com/sun/mail/imap/protocol/FetchResponse.java Wed Oct 21 09:11:35 2015 +0200
@@ -65,7 +65,7 @@
      * regular items and extension items.
      */
     private Item[] items;
- private Map extensionItems;
+ private Map<String, Object> extensionItems;
     private final FetchItem[] fitems;
 
     public FetchResponse(Protocol p)
@@ -188,7 +188,7 @@
      * @return Map of extension items, or null if none
      * @since JavaMail 1.4.6
      */
- public Map getExtensionItems() {
+ public Map<String, Object> getExtensionItems() {
         return extensionItems;
     }
 
@@ -298,7 +298,7 @@
         for (int i = 0; i < fitems.length; i++) {
             if (match(fitems[i].getName())) {
                 if (extensionItems == null)
- extensionItems = new HashMap();
+ extensionItems = new HashMap<String, Object>();
                 extensionItems.put(fitems[i].getName(),
                                     fitems[i].parseItem(this));
                 return true;

diff -r 5d0dac7b71d2 -r 88dfebaed1fa mail/src/main/java/com/sun/mail/imap/protocol/IMAPProtocol.java
--- a/mail/src/main/java/com/sun/mail/imap/protocol/IMAPProtocol.java Tue Oct 20 12:39:10 2015 -0700
+++ b/mail/src/main/java/com/sun/mail/imap/protocol/IMAPProtocol.java Wed Oct 21 09:11:35 2015 +0200
@@ -85,10 +85,10 @@
     // WARNING: authenticated may be set to true in superclass
     // constructor, don't initialize it here.
 
- private Map capabilities;
+ private Map<String, String> capabilities;
     // WARNING: capabilities may be initialized as a result of superclass
     // constructor, don't initialize it here.
- private List authmechs;
+ private List<String> authmechs;
     // WARNING: authmechs may be initialized as a result of superclass
     // constructor, don't initialize it here.
 
@@ -178,7 +178,7 @@
             !PropUtil.getBooleanProperty(props, "mail.debug.auth", false);
 
         if (capabilities == null)
- capabilities = new HashMap();
+ capabilities = new HashMap<String, String>();
 
         searchCharsets = new String[2]; // 2, for now.
         searchCharsets[0] = "UTF-8";
@@ -214,8 +214,8 @@
         Response response = r[r.length-1];
 
         if (response.isOK()) {
- capabilities = new HashMap(10);
- authmechs = new ArrayList(5);
+ capabilities = new HashMap<String, String>(10);
+ authmechs = new ArrayList<String>(5);
             for (int i = 0, len = r.length; i < len; i++) {
                 if (!(r[i] instanceof IMAPResponse))
                     continue;
@@ -249,8 +249,8 @@
         s = r.readAtom();
         if (!s.equalsIgnoreCase("CAPABILITY"))
             return;
- capabilities = new HashMap(10);
- authmechs = new ArrayList(5);
+ capabilities = new HashMap<String, String>(10);
+ authmechs = new ArrayList<String>(5);
         parseCapabilities(r);
     }
 
@@ -404,9 +404,9 @@
     public boolean hasCapability(String c) {
         if (c.endsWith("*")) {
             c = c.substring(0, c.length() - 1).toUpperCase(Locale.ENGLISH);
- Iterator it = capabilities.keySet().iterator();
+ Iterator<String> it = capabilities.keySet().iterator();
             while (it.hasNext()) {
- if (((String)it.next()).startsWith(c))
+ if (it.next().startsWith(c))
                     return true;
             }
             return false;
@@ -420,7 +420,7 @@
      * @return the Map of capabilities
      * @since JavaMail 1.4.1
      */
- public Map getCapabilities() {
+ public Map<String, String> getCapabilities() {
         return capabilities;
     }
 
@@ -933,9 +933,9 @@
             serviceHost = host;
         if (saslAuthenticator == null) {
             try {
- Class sac = Class.forName(
+ Class<?> sac = Class.forName(
                     "com.sun.mail.imap.protocol.IMAPSaslAuthenticator");
- Constructor c = sac.getConstructor(new Class[] {
+ Constructor<?> c = sac.getConstructor(new Class<?>[] {
                                         IMAPProtocol.class,
                                         String.class,
                                         Properties.class,
@@ -958,10 +958,10 @@
         }
 
         // were any allowed mechanisms specified?
- List v;
+ List<String> v;
         if (allowed != null && allowed.length > 0) {
             // remove anything not supported by the server
- v = new ArrayList(allowed.length);
+ v = new ArrayList<String>(allowed.length);
             for (int i = 0; i < allowed.length; i++)
                 if (authmechs.contains(allowed[i])) // XXX - case must match
                     v.add(allowed[i]);
@@ -969,7 +969,7 @@
             // everything is allowed
             v = authmechs;
         }
- String[] mechs = (String[])v.toArray(new String[v.size()]);
+ String[] mechs = v.toArray(new String[v.size()]);
 
         try {
 
@@ -2069,7 +2069,7 @@
         Response[] r = command("UID FETCH " + msgSequence +
                 " (FLAGS) (CHANGEDSINCE " + String.valueOf(modseq) + ")", null);
 
- List v = new ArrayList();
+ List<Integer> v = new ArrayList<Integer>();
         for (int i = 0, len = r.length; i < len; i++) {
             if (r[i] == null || !(r[i] instanceof FetchResponse))
                 continue;
@@ -2085,7 +2085,7 @@
         int vsize = v.size();
         int[] matches = new int[vsize];
         for (int i = 0; i < vsize; i++)
- matches[i] = ((Integer)v.get(i)).intValue();
+ matches[i] = v.get(i).intValue();
         return matches;
     }
 
@@ -2708,7 +2708,7 @@
 
         Response response = r[r.length-1];
 
- Hashtable tab = new Hashtable();
+ Hashtable<String, Quota> tab = new Hashtable<String, Quota>();
 
         // Grab all QUOTAROOT and QUOTA responses
         if (response.isOK()) { // command succesful
@@ -2731,7 +2731,7 @@
                     r[i] = null;
                 } else if (ir.keyEquals("QUOTA")) {
                     Quota quota = parseQuota(ir);
- Quota q = (Quota)tab.get(quota.quotaRoot);
+ Quota q = tab.get(quota.quotaRoot);
                     if (q != null && q.resources != null) {
                         // merge resources
                         int newl = q.resources.length + quota.resources.length;
@@ -2753,9 +2753,9 @@
         handleResult(response);
 
         Quota[] qa = new Quota[tab.size()];
- Enumeration e = tab.elements();
+ Enumeration<Quota> e = tab.elements();
         for
[truncated due to length]