commits@javamail.java.net

[javamail~mercurial:384] Fold Content-Language header.

From: <shannon_at_kenai.com>
Date: Fri, 2 Sep 2011 23:49:54 +0000

Project: javamail
Repository: mercurial
Revision: 384
Author: shannon
Date: 2011-09-02 22:09:00 UTC
Link:

Log Message:
------------
Fix some javadoc errors.
Update pom.xml to support deployment to new java.net maven repository.
Free MIME headers in IMAPMessage.invalidateHeaders.
Update table to indicate that pop3 supports STARTTLS.
Fix exception in POP3Message when reading file cached content twice.
If the STLS command fails, and mail.pop3.starttls.required is set, fail.
Convert MIME charset to Java charset before using.
Avoid possible NPE with bogus blank line response.
Fold Content-Language header.


Revisions:
----------
376
377
378
379
380
381
382
383
384


Modified Paths:
---------------
mail/src/main/java/com/sun/mail/handlers/image_gif.java
mail/src/main/java/com/sun/mail/handlers/message_rfc822.java
mail/src/main/java/com/sun/mail/handlers/multipart_mixed.java
mail/src/main/java/com/sun/mail/iap/Argument.java
mail/src/main/java/com/sun/mail/imap/protocol/IMAPProtocol.java
mail/src/main/java/com/sun/mail/imap/protocol/Item.java
mail/src/main/java/com/sun/mail/imap/protocol/Namespaces.java
mail/src/main/java/com/sun/mail/imap/protocol/RFC822DATA.java
mail/src/main/java/com/sun/mail/imap/protocol/RFC822SIZE.java
pom.xml
doc/release/CHANGES.txt
mail/src/main/java/com/sun/mail/imap/IMAPMessage.java
doc/release/README.txt
mail/src/main/java/com/sun/mail/pop3/POP3Message.java
mail/src/test/java/com/sun/mail/pop3/POP3MessageTest.java
mail/src/main/java/com/sun/mail/pop3/POP3Store.java
mail/src/main/java/javax/mail/util/ByteArrayDataSource.java
mail/src/main/java/com/sun/mail/iap/Response.java
mail/src/main/java/javax/mail/internet/MimeBodyPart.java


Added Paths:
------------
mail/src/test/java/javax/mail/internet/MimeBodyPartTest.java


Diffs:
------
diff -r 45770b43aa92 -r e5efbaaf6dc9 mail/src/main/java/com/sun/mail/handlers/image_gif.java
--- a/mail/src/main/java/com/sun/mail/handlers/image_gif.java Mon Jul 11 16:30:21 2011 -0700
+++ b/mail/src/main/java/com/sun/mail/handlers/image_gif.java Fri Jul 22 15:26:15 2011 -0700
@@ -1,7 +1,7 @@
 /*
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
  *
- * Copyright (c) 1997-2010 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2011 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
@@ -72,7 +72,7 @@
      * Return the Transfer Data of type DataFlavor from InputStream.
      *
      * @param df The DataFlavor
- * @param ins The InputStream corresponding to the data
+ * @param ds The DataSource corresponding to the data
      * @return String object
      */
     public Object getTransferData(DataFlavor df, DataSource ds)

diff -r 45770b43aa92 -r e5efbaaf6dc9 mail/src/main/java/com/sun/mail/handlers/message_rfc822.java
--- a/mail/src/main/java/com/sun/mail/handlers/message_rfc822.java Mon Jul 11 16:30:21 2011 -0700
+++ b/mail/src/main/java/com/sun/mail/handlers/message_rfc822.java Fri Jul 22 15:26:15 2011 -0700
@@ -1,7 +1,7 @@
 /*
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
  *
- * Copyright (c) 1997-2010 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2011 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
@@ -71,7 +71,7 @@
     /**
      * return the Transfer Data of type DataFlavor from InputStream
      * @param df The DataFlavor.
- * @param ins The InputStream corresponding to the data.
+ * @param ds The DataSource corresponding to the data
      * @return a Message object
      */
     public Object getTransferData(DataFlavor df, DataSource ds)

diff -r 45770b43aa92 -r e5efbaaf6dc9 mail/src/main/java/com/sun/mail/handlers/multipart_mixed.java
--- a/mail/src/main/java/com/sun/mail/handlers/multipart_mixed.java Mon Jul 11 16:30:21 2011 -0700
+++ b/mail/src/main/java/com/sun/mail/handlers/multipart_mixed.java Fri Jul 22 15:26:15 2011 -0700
@@ -1,7 +1,7 @@
 /*
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
  *
- * Copyright (c) 1997-2010 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2011 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 @@
      * Return the Transfer Data of type DataFlavor from InputStream.
      *
      * @param df The DataFlavor
- * @param ins The InputStream corresponding to the data
+ * @param ds The DataSource corresponding to the data
      * @return String object
      */
     public Object getTransferData(DataFlavor df, DataSource ds)

diff -r 45770b43aa92 -r e5efbaaf6dc9 mail/src/main/java/com/sun/mail/iap/Argument.java
--- a/mail/src/main/java/com/sun/mail/iap/Argument.java Mon Jul 11 16:30:21 2011 -0700
+++ b/mail/src/main/java/com/sun/mail/iap/Argument.java Fri Jul 22 15:26:15 2011 -0700
@@ -1,7 +1,7 @@
 /*
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
  *
- * Copyright (c) 1997-2010 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2011 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
@@ -146,7 +146,6 @@
 
     /**
      * Write out as parenthesised list.
- * @param s statement
      */
     public void writeArgument(Argument c) {
         items.addElement(c);

diff -r 45770b43aa92 -r e5efbaaf6dc9 mail/src/main/java/com/sun/mail/imap/protocol/IMAPProtocol.java
--- a/mail/src/main/java/com/sun/mail/imap/protocol/IMAPProtocol.java Mon Jul 11 16:30:21 2011 -0700
+++ b/mail/src/main/java/com/sun/mail/imap/protocol/IMAPProtocol.java Fri Jul 22 15:26:15 2011 -0700
@@ -707,7 +707,9 @@
     /**
      * ID Command, for Yahoo! Mail IMAP server.
      *
- * @see http://en.wikipedia.org/wiki/Yahoo%21_Mail#Free_IMAP_and_SMTPs_access
+ * See <A HREF="http://en.wikipedia.org/wiki/Yahoo%21_Mail#Free_IMAP_and_SMTPs_access">
+ * http://en.wikipedia.org/wiki/Yahoo%21_Mail#Free_IMAP_and_SMTPs_access</A>
+ *
      * @since JavaMail 1.4.4
      */
     public void id(String guid) throws ProtocolException {

diff -r 45770b43aa92 -r e5efbaaf6dc9 mail/src/main/java/com/sun/mail/imap/protocol/Item.java
--- a/mail/src/main/java/com/sun/mail/imap/protocol/Item.java Mon Jul 11 16:30:21 2011 -0700
+++ b/mail/src/main/java/com/sun/mail/imap/protocol/Item.java Fri Jul 22 15:26:15 2011 -0700
@@ -1,7 +1,7 @@
 /*
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
  *
- * Copyright (c) 1997-2010 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2011 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,11 +42,12 @@
 
 /**
  * A tagging interface for all IMAP data items.
- * Note that the "name" field of all IMAP items MUST be in uppercase.
+ * Note that the "name" field of all IMAP items MUST be in uppercase. <p>
+ *
+ * See the BODY, BODYSTRUCTURE, ENVELOPE, FLAGS, INTERNALDATE, RFC822DATA,
+ * RFC822SIZE, and UID classes.
  *
  * @author John Mani
- * @see BODY, BODYSTRUCTURE, ENVELOPE, FLAGS, INTERNALDATE, RFC822DATA,
- * RFC822SIZE, UID
  */
 
 public interface Item {

diff -r 45770b43aa92 -r e5efbaaf6dc9 mail/src/main/java/com/sun/mail/imap/protocol/Namespaces.java
--- a/mail/src/main/java/com/sun/mail/imap/protocol/Namespaces.java Mon Jul 11 16:30:21 2011 -0700
+++ b/mail/src/main/java/com/sun/mail/imap/protocol/Namespaces.java Fri Jul 22 15:26:15 2011 -0700
@@ -1,7 +1,7 @@
 /*
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
  *
- * Copyright (c) 1997-2010 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2011 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
@@ -45,9 +45,10 @@
 
 /**
  * This class and its inner class represent the response to the
- * NAMESPACE command.
+ * NAMESPACE command. <p>
  *
- * @see RFC2342
+ * See <A HREF="http://www.ietf.org/rfc/rfc2342.txt">RFC 2342</A>.
+ *
  * @author Bill Shannon
  */
 

diff -r 45770b43aa92 -r e5efbaaf6dc9 mail/src/main/java/com/sun/mail/imap/protocol/RFC822DATA.java
--- a/mail/src/main/java/com/sun/mail/imap/protocol/RFC822DATA.java Mon Jul 11 16:30:21 2011 -0700
+++ b/mail/src/main/java/com/sun/mail/imap/protocol/RFC822DATA.java Fri Jul 22 15:26:15 2011 -0700
@@ -1,7 +1,7 @@
 /*
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
  *
- * Copyright (c) 1997-2010 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2011 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
@@ -58,7 +58,6 @@
 
     /**
      * Constructor
- * @param port portnumber to connect to
      */
     public RFC822DATA(FetchResponse r) throws ParsingException {
         msgno = r.getNumber();

diff -r 45770b43aa92 -r e5efbaaf6dc9 mail/src/main/java/com/sun/mail/imap/protocol/RFC822SIZE.java
--- a/mail/src/main/java/com/sun/mail/imap/protocol/RFC822SIZE.java Mon Jul 11 16:30:21 2011 -0700
+++ b/mail/src/main/java/com/sun/mail/imap/protocol/RFC822SIZE.java Fri Jul 22 15:26:15 2011 -0700
@@ -1,7 +1,7 @@
 /*
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
  *
- * Copyright (c) 1997-2010 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2011 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
@@ -57,7 +57,6 @@
 
     /**
      * Constructor
- * @param port portnumber to connect to
      */
     public RFC822SIZE(FetchResponse r) throws ParsingException {
         msgno = r.getNumber();


diff -r e5efbaaf6dc9 -r 515045c64df3 pom.xml
--- a/pom.xml Fri Jul 22 15:26:15 2011 -0700
+++ b/pom.xml Tue Aug 02 14:24:27 2011 -0700
@@ -45,6 +45,11 @@
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
                             http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>net.java</groupId>
+ <artifactId>jvnet-parent</artifactId>
+ <version>1</version>
+ </parent>
     <modelVersion>4.0.0</modelVersion>
     <groupId>com.sun.mail</groupId>
     <artifactId>all</artifactId>
@@ -54,6 +59,17 @@
     <description>${project.name}</description>
     <url>http://kenai.com/projects/javamail</url>
 
+ <scm>
+ <connection>scm:hg:http://kenai.com/hg/javamail~mercurial</connection>
+ <developerConnection>scm:hg:https://kenai.com/hg/javamail~mercurial</developerConnection>
+ <url>http://kenai.com/hg/javamail~mercurial</url>
+ </scm>
+
+ <issueManagement>
+ <system>Bugzilla</system>
+ <url>http://kenai.com/bugzilla</url>
+ </issueManagement>
+
     <licenses>
       <license>
         <name>CDDL</name>
@@ -168,6 +184,8 @@
         </profile>
 
         <!--
+ This profile is used for deploying a JavaMail final release.
+
             Activating this profile manually for deployment causes
             the above profile to be deactivated, which works around
             an apparent bug in maven that prevents me from manually
@@ -175,7 +193,7 @@
             of the modules I don't want to be deployed.
         -->
         <profile>
- <id>deploy</id>
+ <id>deploy-release</id>
             <modules>
                 <module>parent-distrib</module>
             </modules>
@@ -188,6 +206,72 @@
                             <skip>true</skip>
                         </configuration>
                     </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <version>2.7</version>
+ <executions>
+ <execution>
+ <id>attach-javadocs</id>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-gpg-plugin</artifactId>
+ <version>1.1</version>
+ <executions>
+ <execution>
+ <id>sign-artifacts</id>
+ <phase>verify</phase>
+ <goals>
+ <goal>sign</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+
+ <!--
+ This profile is used for deploying a JavaMail SNAPSHOT release.
+ It's identical to the above deploy-release profile except that
+ artifacts aren't signed.
+ -->
+ <profile>
+ <id>deploy-snapshot</id>
+ <modules>
+ <module>parent-distrib</module>
+ </modules>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <version>2.7</version>
+ <executions>
+ <execution>
+ <id>attach-javadocs</id>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
                 </plugins>
             </build>
         </profile>
@@ -232,16 +316,6 @@
         </profile>
     </profiles>
 
- <distributionManagement>
- <repository>
- <id>java.net-m2-repository</id>
- <url>
- svn:https://svn.java.net/svn/maven2-repository~svn/trunk/repository
- </url>
- <uniqueVersion>false</uniqueVersion>
- </repository>
- </distributionManagement>
-
     <build>
         <defaultGoal>install</defaultGoal>
         <plugins>
@@ -541,20 +615,6 @@
                  </plugin>
             </plugins>
         </pluginManagement>
-
- <extensions>
- <extension>
- <groupId>org.jvnet.wagon-svn</groupId>
- <artifactId>wagon-svn</artifactId>
- <!--
- Following should be:
- <version>RELEASE</version>
- but Kohsuke says it doesn't work and to replace
- it with the actual version number.
- -->
- <version>1.8</version>
- </extension>
- </extensions>
     </build>
 
     <dependencyManagement>
@@ -600,22 +660,6 @@
         </dependency>
     </dependencies>
 
- <repositories>
- <repository>
- <id>maven2-repository.dev.java.net</id>
- <name>Java.net Repository for Maven</name>
- <url>http://download.java.net/maven/2/</url>
- </repository>
- </repositories>
-
- <pluginRepositories>
- <pluginRepository>
- <id>glassfish-repo-archive</id>
- <name>M2 repo for GlassFish project specific artifacts</name>
- <url>http://download.java.net/maven/glassfish/</url>
- </pluginRepository>
- </pluginRepositories>
-
     <reporting>
         <plugins>
             <!--


diff -r 515045c64df3 -r c202cdce11e9 doc/release/CHANGES.txt
--- a/doc/release/CHANGES.txt Tue Aug 02 14:24:27 2011 -0700
+++ b/doc/release/CHANGES.txt Fri Sep 02 13:52:40 2011 -0700
@@ -22,6 +22,7 @@
 K 4002 MultipartReport.setReport and setDeliveryStatus are broken
 K 4065 Wrong representation of CR/LF are appended to the attachment
 <no id> properly handle timeouts during SSL negotiation
+<no id> free MIME headers in IMAPMessage.invalidateHeaders
 
 
                   CHANGES IN THE 1.4.4 RELEASE

diff -r 515045c64df3 -r c202cdce11e9 mail/src/main/java/com/sun/mail/imap/IMAPMessage.java
--- a/mail/src/main/java/com/sun/mail/imap/IMAPMessage.java Tue Aug 02 14:24:27 2011 -0700
+++ b/mail/src/main/java/com/sun/mail/imap/IMAPMessage.java Fri Sep 02 13:52:40 2011 -0700
@@ -916,6 +916,7 @@
     public synchronized void invalidateHeaders() {
         headersLoaded = false;
         loadedHeaders.clear();
+ headers = null;
         envelope = null;
         bs = null;
         receivedDate = null;


diff -r c202cdce11e9 -r 52db41c46c0a doc/release/README.txt
--- a/doc/release/README.txt Fri Sep 02 13:52:40 2011 -0700
+++ b/doc/release/README.txt Fri Sep 02 13:53:25 2011 -0700
@@ -39,11 +39,11 @@
         Name Transport? SSL? STARTTLS?
         -------------------------------------------------
         imap Store No Yes
- imaps Store Yes Yes
- pop3 Store No No
- pop3s Store Yes No
+ imaps Store Yes N/A
+ pop3 Store No Yes
+ pop3s Store Yes N/A
         smtp Transport No Yes
- smtps Transport Yes Yes
+ smtps Transport Yes N/A
 
 See our web page at http://www.oracle.com/technetwork/java/javamail/
 for the latest information on third party protocol providers.


diff -r 52db41c46c0a -r 456f918b8270 doc/release/CHANGES.txt
--- a/doc/release/CHANGES.txt Fri Sep 02 13:53:25 2011 -0700
+++ b/doc/release/CHANGES.txt Fri Sep 02 14:17:20 2011 -0700
@@ -23,6 +23,7 @@
 K 4065 Wrong representation of CR/LF are appended to the attachment
 <no id> properly handle timeouts during SSL negotiation
 <no id> free MIME headers in IMAPMessage.invalidateHeaders
+<no id> fix exception in POP3Message when reading file cached content twice
 
 
                   CHANGES IN THE 1.4.4 RELEASE

diff -r 52db41c46c0a -r 456f918b8270 mail/src/main/java/com/sun/mail/pop3/POP3Message.java
--- a/mail/src/main/java/com/sun/mail/pop3/POP3Message.java Fri Sep 02 13:53:25 2011 -0700
+++ b/mail/src/main/java/com/sun/mail/pop3/POP3Message.java Fri Sep 02 14:17:20 2011 -0700
@@ -245,13 +245,15 @@
                         ((POP3Store)(folder.getStore())).keepMessageContent)
                     contentStream = cstream;
                 contentData = new SoftReference(cstream);
- } else {
- /*
- * We have a cached stream, but we need to return
- * a fresh stream to read from the beginning.
- */
                 cstream = ((SharedInputStream)cstream).newStream(0, -1);
             }
+
+ /*
+ * We have a cached stream, but we need to return
+ * a fresh stream to read from the beginning and
+ * that can be safely closed.
+ */
+ cstream = ((SharedInputStream)cstream).newStream(0, -1);
         }
         } catch (EOFException eex) {
             folder.close(false);

diff -r 52db41c46c0a -r 456f918b8270 mail/src/test/java/com/sun/mail/pop3/POP3MessageTest.java
--- a/mail/src/test/java/com/sun/mail/pop3/POP3MessageTest.java Fri Sep 02 13:53:25 2011 -0700
+++ b/mail/src/test/java/com/sun/mail/pop3/POP3MessageTest.java Fri Sep 02 14:17:20 2011 -0700
@@ -1,7 +1,7 @@
 /*
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
  *
- * Copyright (c) 2009-2010 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009-2011 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
@@ -68,8 +68,7 @@
     private static Store store;
     private static Folder folder;
 
- @BeforeClass
- public static void startServer() {
+ private static void startServer(boolean cached) {
         try {
             final POP3Handler handler = new POP3Handler();
             server = new POP3Server(handler, 26421);
@@ -79,6 +78,8 @@
             final Properties properties = new Properties();
             properties.setProperty("mail.pop3.host", "localhost");
             properties.setProperty("mail.pop3.port", "26421");
+ if (cached)
+ properties.setProperty("mail.pop3.filecache.enable", "true");
             final Session session = Session.getInstance(properties);
             //session.setDebug(true);
 
@@ -92,8 +93,7 @@
         }
     }
 
- @AfterClass
- public static void stopServer() {
+ private static void stopServer() {
         try {
             if (folder != null)
                 folder.close(false);
@@ -113,15 +113,30 @@
      * second time, instead of a new stream positioned at the
      * beginning of the data. This caused multipart parsing
      * to fail.
- *
- * XXX - really should test this with all the various caching options
      */
     @Test
     public void testReadTwice() throws Exception {
- Message[] msgs = folder.getMessages();
- for (int i = 0; i < msgs.length; i++) {
- loadMail(msgs[i]);
- loadMail(msgs[i]);
+ readTwice(false);
+ }
+
+ /**
+ * Now test it using the file cache.
+ */
+ @Test
+ public void testReadTwiceCached() throws Exception {
+ readTwice(true);
+ }
+
+ private void readTwice(boolean cached) throws Exception {
+ startServer(cached);
+ try {
+ Message[] msgs = folder.getMessages();
+ for (int i = 0; i < msgs.length; i++) {
+ loadMail(msgs[i]);
+ loadMail(msgs[i]);
+ }
+ } finally {
+ stopServer();
         }
         // no exception is success!
     }


diff -r 456f918b8270 -r b9e1b30cf7f4 mail/src/main/java/com/sun/mail/pop3/POP3Store.java
--- a/mail/src/main/java/com/sun/mail/pop3/POP3Store.java Fri Sep 02 14:17:20 2011 -0700
+++ b/mail/src/main/java/com/sun/mail/pop3/POP3Store.java Fri Sep 02 14:19:11 2011 -0700
@@ -263,9 +263,19 @@
 
         if (useStartTLS || requireStartTLS) {
             if (p.hasCapability("STLS")) {
- p.stls();
- // refresh capabilities
- p.setCapabilities(p.capa());
+ if (p.stls()) {
+ // success, refresh capabilities
+ p.setCapabilities(p.capa());
+ } else if (requireStartTLS) {
+ if (debug)
+ out.println("DEBUG POP3: STLS required but failed");
+ try {
+ p.quit();
+ } catch (IOException ioex) {
+ } finally {
+ throw new EOFException("STLS required but failed");
+ }
+ }
             } else if (requireStartTLS) {
                 if (debug)
                     out.println("DEBUG POP3: STLS required but not supported");


diff -r b9e1b30cf7f4 -r 0e779f965f41 mail/src/main/java/javax/mail/util/ByteArrayDataSource.java
--- a/mail/src/main/java/javax/mail/util/ByteArrayDataSource.java Fri Sep 02 14:19:11 2011 -0700
+++ b/mail/src/main/java/javax/mail/util/ByteArrayDataSource.java Fri Sep 02 14:20:10 2011 -0700
@@ -1,7 +1,7 @@
 /*
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
  *
- * Copyright (c) 1997-2010 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2011 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
@@ -135,6 +135,7 @@
         } catch (ParseException pex) {
             // ignore parse error
         }
+ charset = MimeUtility.javaCharset(charset);
         if (charset == null)
             charset = MimeUtility.getDefaultJavaCharset();
         // XXX - could convert to bytes on demand rather than copying here


diff -r 0e779f965f41 -r cf8a9d102844 mail/src/main/java/com/sun/mail/iap/Response.java
--- a/mail/src/main/java/com/sun/mail/iap/Response.java Fri Sep 02 14:20:10 2011 -0700
+++ b/mail/src/main/java/com/sun/mail/iap/Response.java Fri Sep 02 14:21:53 2011 -0700
@@ -1,7 +1,7 @@
 /*
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
  *
- * Copyright (c) 1997-2010 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2011 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
@@ -125,6 +125,8 @@
     private void parse() {
         index = 0; // position internal index at start
 
+ if (size == 0) // empty line
+ return;
         if (buffer[index] == '+') { // Continuation statement
             type |= CONTINUATION;
             index += 1; // Position beyond the '+'
@@ -135,6 +137,8 @@
         } else { // Tagged statement
             type |= TAGGED;
             tag = readAtom(); // read the TAG, index positioned beyond tag
+ if (tag == null)
+ tag = ""; // avoid possible NPE
         }
 
         int mark = index; // mark


diff -r cf8a9d102844 -r 3b2c104e3bc2 mail/src/main/java/javax/mail/internet/MimeBodyPart.java
--- a/mail/src/main/java/javax/mail/internet/MimeBodyPart.java Fri Sep 02 14:21:53 2011 -0700
+++ b/mail/src/main/java/javax/mail/internet/MimeBodyPart.java Fri Sep 02 15:09:00 2011 -0700
@@ -1,7 +1,7 @@
 /*
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
  *
- * Copyright (c) 1997-2010 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2011 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
@@ -1227,8 +1227,17 @@
     static void setContentLanguage(MimePart part, String[] languages)
                         throws MessagingException {
         StringBuffer sb = new StringBuffer(languages[0]);
- for (int i = 1; i < languages.length; i++)
- sb.append(',').append(languages[i]);
+ int len = "Content-Language".length() + 2 + languages[0].length();
+ for (int i = 1; i < languages.length; i++) {
+ sb.append(',');
+ len++;
+ if (len > 76) {
+ sb.append("\r\n\t");
+ len = 8;
+ }
+ sb.append(languages[i]);
+ len += languages[i].length();
+ }
         part.setHeader("Content-Language", sb.toString());
     }
 

diff -r cf8a9d102844 -r 3b2c104e3bc2 mail/src/test/java/javax/mail/internet/MimeBodyPartTest.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mail/src/test/java/javax/mail/internet/MimeBodyPartTest.java Fri Sep 02 15:09:00 2011 -0700
@@ -0,0 +1,72 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2011 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 org.junit.*;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertArrayEquals;
+
+/**
+ * Test the MimeBodyPart class.
+ */
+public class MimeBodyPartTest {
+
+ private static String[] languages = new String[] {
+ "language1", "language2", "language3", "language4", "language5",
+ "language6", "language7", "language8", "language9", "language10",
+ "language11", "language12", "language13", "language14", "language15"
+ };
+
+ /**
+ * Test that the Content-Language header is properly folded
+ * if there are a lot of languages.
+ */
+ @Test
+ public void testContentLanguageFold() throws Exception {
+ MimeBodyPart mbp = new MimeBodyPart();
+ mbp.setContentLanguage(languages);
+ String header = mbp.getHeader("Content-Language", ",");
+ assertTrue(header.indexOf("\r\n") > 0);
+
+ String[] langs = mbp.getContentLanguage();
+ assertArrayEquals(languages, langs);
+ }
+}