commits@javamail.java.net

[javamail~mercurial:374] Don't quote user names that include ".", trim leading and trailing whites

From: <shannon_at_kenai.com>
Date: Fri, 24 Jun 2011 19:16:43 +0000

Project: javamail
Repository: mercurial
Revision: 374
Author: shannon
Date: 2011-06-21 00:29:23 UTC
Link:

Log Message:
------------
Remove findbugs dependency left in by mistake.
Can't make these fields volatile because it breaks the TCK
signature tests.
Properly handle timeouts during SSL negotiation.
Include source code in source jar files for artifacts created using
the maven-dependency-plugin.
Move the build helper and source plugin configuration to the top level;
now every module builds a source jar.
Changes from Jason:

LogManagerProperties make clone copy any cached properties.
LogManagerPropertiesTest new test file.
MailHandler increase max byte buffer for body content type test.
MailHandler allow reentrance on publish from push filter.
MailHandler IllegalStateException for reentrance on publish from non-push filter.
MailHandler pass mime message used during verify to reportError.
MailHandler create subject during verify for reportError.
MailHandler BUGID 6995537 PrintStream.close and flushBuffer
MailHandlerTest add tests for reentrance on publish.
MailHandlerTest fixed wrong subject key.
MailHandlerTest add test for verify to ensure a MimeMessage is sent to reportError.
Don't quote user names that include ".", trim leading and trailing whitespace.


Revisions:
----------
368
369
370
371
372
373
374


Modified Paths:
---------------
pom.xml
mail/src/main/java/javax/mail/Message.java
mail/src/main/java/javax/mail/internet/MimeMessage.java
doc/release/CHANGES.txt
mail/src/main/java/com/sun/mail/util/SocketFetcher.java
mailapi/pom.xml
mailapijar/pom.xml
oldmail/pom.xml
parent-distrib/pom.xml
mail/src/main/java/com/sun/mail/util/logging/LogManagerProperties.java
mail/src/main/java/com/sun/mail/util/logging/MailHandler.java
mail/src/test/java/com/sun/mail/util/logging/MailHandlerTest.java
mail/src/main/java/javax/mail/internet/InternetAddress.java


Added Paths:
------------
mail/src/test/java/com/sun/mail/util/logging/LogManagerPropertiesTest.java


Diffs:
------
diff -r 8013b296e845 -r 2c35b8c94693 pom.xml
--- a/pom.xml Wed Mar 09 11:10:06 2011 -0800
+++ b/pom.xml Tue Mar 29 14:41:42 2011 -0700
@@ -476,13 +476,6 @@
                             ${findbugs.exclude}
                         </excludeFilterFile>
                     </configuration>
- <dependencies>
- <dependency>
- <groupId>com.sun.mail</groupId>
- <artifactId>findbugs</artifactId>
- <version>${mail.version}</version>
- </dependency>
- </dependencies>
                 </plugin>
                 <plugin>
                     <groupId>org.apache.maven.plugins</groupId>


diff -r 2c35b8c94693 -r c939245d150a mail/src/main/java/javax/mail/Message.java
--- a/mail/src/main/java/javax/mail/Message.java Tue Mar 29 14:41:42 2011 -0700
+++ b/mail/src/main/java/javax/mail/Message.java Thu Apr 07 16:42:02 2011 -0700
@@ -86,7 +86,7 @@
      * The number of this message within its folder, or zero if
      * the message was not retrieved from a folder.
      */
- protected volatile int msgnum = 0;
+ protected int msgnum = 0;
 
     /**
      * True if this message has been expunged.

diff -r 2c35b8c94693 -r c939245d150a mail/src/main/java/javax/mail/internet/MimeMessage.java
--- a/mail/src/main/java/javax/mail/internet/MimeMessage.java Tue Mar 29 14:41:42 2011 -0700
+++ b/mail/src/main/java/javax/mail/internet/MimeMessage.java Thu Apr 07 16:42:02 2011 -0700
@@ -132,7 +132,7 @@
     /**
      * The Flags for this message.
      */
- protected volatile Flags flags;
+ protected Flags flags;
 
     /**
      * A flag indicating whether the message has been modified.


diff -r c939245d150a -r 96d2f2d6dfa9 doc/release/CHANGES.txt
--- a/doc/release/CHANGES.txt Thu Apr 07 16:42:02 2011 -0700
+++ b/doc/release/CHANGES.txt Tue May 24 14:27:49 2011 -0700
@@ -21,6 +21,7 @@
 7021190 MimeMessage.setRecipients(type, String) does not accept null address
 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
 
 
                   CHANGES IN THE 1.4.4 RELEASE

diff -r c939245d150a -r 96d2f2d6dfa9 mail/src/main/java/com/sun/mail/util/SocketFetcher.java
--- a/mail/src/main/java/com/sun/mail/util/SocketFetcher.java Thu Apr 07 16:42:02 2011 -0700
+++ b/mail/src/main/java/com/sun/mail/util/SocketFetcher.java Tue May 24 14:27:49 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
@@ -157,6 +157,7 @@
 
         int sfPort = -1;
         String sfErr = "unknown socket factory";
+ int to = PropUtil.getIntProperty(props, prefix + ".timeout", -1);
         try {
             /*
              * If using SSL, first look for SSL-specific class name or
@@ -203,7 +204,7 @@
                 if (sfPort == -1)
                     sfPort = port;
                 socket = createSocket(localaddr, localport,
- host, sfPort, cto, props, prefix, sf, useSSL, idCheck);
+ host, sfPort, cto, to, props, prefix, sf, useSSL, idCheck);
             }
         } catch (SocketTimeoutException sex) {
             throw sex;
@@ -227,13 +228,14 @@
             }
         }
 
- if (socket == null)
+ if (socket == null) {
             socket = createSocket(localaddr, localport,
- host, port, cto, props, prefix, null, useSSL, idCheck);
+ host, port, cto, to, props, prefix, null, useSSL, idCheck);
 
- int to = PropUtil.getIntProperty(props, prefix + ".timeout", -1);
- if (to >= 0)
- socket.setSoTimeout(to);
+ } else {
+ if (to >= 0)
+ socket.setSoTimeout(to);
+ }
 
         configureSSLSocket(socket, props, prefix);
         return socket;
@@ -246,12 +248,13 @@
 
     /**
      * Create a socket with the given local address and connected to
- * the given host and port. Use the specified connection timeout.
+ * the given host and port. Use the specified connection timeout
+ * and read timeout.
      * If a socket factory is specified, use it. Otherwise, use the
      * SSLSocketFactory if useSSL is true.
      */
     private static Socket createSocket(InetAddress localaddr, int localport,
- String host, int port, int cto,
+ String host, int port, int cto, int to,
                                 Properties props, String prefix,
                                 SocketFactory sf, boolean useSSL,
                                 boolean idCheck) throws IOException {
@@ -280,6 +283,8 @@
             socket = sf.createSocket();
         } else
             socket = new Socket();
+ if (to >= 0)
+ socket.setSoTimeout(to);
         if (localaddr != null)
             socket.bind(new InetSocketAddress(localaddr, localport));
         if (cto >= 0)


diff -r 96d2f2d6dfa9 -r 5a6324983177 mailapi/pom.xml
--- a/mailapi/pom.xml Tue May 24 14:27:49 2011 -0700
+++ b/mailapi/pom.xml Tue May 24 14:29:18 2011 -0700
@@ -77,17 +77,39 @@
     </properties>
 
     <build>
- <plugins>
+ <plugins>
             <plugin>
                 <artifactId>maven-dependency-plugin</artifactId>
                 <executions>
                     <execution>
- <id>unpack</id>
+ <!-- download the binaries -->
+ <id>get-binaries</id>
                         <phase>process-sources</phase>
                         <goals>
                             <goal>unpack</goal>
                         </goals>
                     </execution>
+ <execution>
+ <!-- download the sources -->
+ <id>get-sources</id>
+ <phase>process-sources</phase>
+ <goals>
+ <goal>unpack</goal>
+ </goals>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>com.sun.mail</groupId>
+ <artifactId>javax.mail</artifactId>
+ <version>${mail.version}</version>
+ <classifier>sources</classifier>
+ <outputDirectory>
+ ${project.build.directory}/sources
+ </outputDirectory>
+ </artifactItem>
+ </artifactItems>
+ </configuration>
+ </execution>
                 </executions>
                 <configuration>
                     <artifactItems>
@@ -122,6 +144,50 @@
                     </archive>
                 </configuration>
             </plugin>
- </plugins>
+
+ <!--
+ Tell the source plugin about the sources downloaded by the
+ maven-dependency-plugin.
+ -->
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>add-source</id>
+ <phase>package</phase>
+ <goals>
+ <goal>add-source</goal>
+ </goals>
+ <configuration>
+ <sources>
+ <source>
+ ${project.build.directory}/sources
+ </source>
+ </sources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <!--
+ Configure the source plugin here so that it will know about
+ the sources downloaded by the maven-dependency-plugin and
+ configured by the build-helper-maven-plugin.
+ -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-source-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>attach-sources</id>
+ <goals>
+ <goal>jar</goal>
+ <goal>jar-no-fork</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
     </build>
 </project>

diff -r 96d2f2d6dfa9 -r 5a6324983177 mailapijar/pom.xml
--- a/mailapijar/pom.xml Tue May 24 14:27:49 2011 -0700
+++ b/mailapijar/pom.xml Tue May 24 14:29:18 2011 -0700
@@ -78,12 +78,34 @@
                 <artifactId>maven-dependency-plugin</artifactId>
                 <executions>
                     <execution>
- <id>unpack</id>
+ <!-- download the binaries -->
+ <id>get-binaries</id>
                         <phase>process-sources</phase>
                         <goals>
                             <goal>unpack</goal>
                         </goals>
                     </execution>
+ <execution>
+ <!-- download the sources -->
+ <id>get-sources</id>
+ <phase>process-sources</phase>
+ <goals>
+ <goal>unpack</goal>
+ </goals>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>com.sun.mail</groupId>
+ <artifactId>javax.mail</artifactId>
+ <version>${mail.version}</version>
+ <classifier>sources</classifier>
+ <outputDirectory>
+ ${project.build.directory}/sources
+ </outputDirectory>
+ </artifactItem>
+ </artifactItems>
+ </configuration>
+ </execution>
                 </executions>
                 <configuration>
                     <artifactItems>
@@ -98,11 +120,8 @@
                     </outputDirectory>
                     <includes>
                         javax/**,
- META-INF/*
+ META-INF/LICENSE.txt
                     </includes>
- <excludes>
- META-INF/javamail.default.*
- </excludes>
                 </configuration>
             </plugin>
             <plugin>
@@ -116,6 +135,50 @@
                     </archive>
                 </configuration>
             </plugin>
+
+ <!--
+ Tell the source plugin about the sources downloaded by the
+ maven-dependency-plugin.
+ -->
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>add-source</id>
+ <phase>package</phase>
+ <goals>
+ <goal>add-source</goal>
+ </goals>
+ <configuration>
+ <sources>
+ <source>
+ ${project.build.directory}/sources
+ </source>
+ </sources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <!--
+ Configure the source plugin here so that it will know about
+ the sources downloaded by the maven-dependency-plugin and
+ configured by the build-helper-maven-plugin.
+ -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-source-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>attach-sources</id>
+ <goals>
+ <goal>jar</goal>
+ <goal>jar-no-fork</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
         </plugins>
     </build>
 </project>

diff -r 96d2f2d6dfa9 -r 5a6324983177 oldmail/pom.xml
--- a/oldmail/pom.xml Tue May 24 14:27:49 2011 -0700
+++ b/oldmail/pom.xml Tue May 24 14:29:18 2011 -0700
@@ -98,12 +98,34 @@
                 <artifactId>maven-dependency-plugin</artifactId>
                 <executions>
                     <execution>
- <id>unpack</id>
+ <!-- download the binaries -->
+ <id>get-binaries</id>
                         <phase>process-sources</phase>
                         <goals>
                             <goal>unpack</goal>
                         </goals>
                     </execution>
+ <execution>
+ <!-- download the sources -->
+ <id>get-sources</id>
+ <phase>process-sources</phase>
+ <goals>
+ <goal>unpack</goal>
+ </goals>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>com.sun.mail</groupId>
+ <artifactId>javax.mail</artifactId>
+ <version>${mail.version}</version>
+ <classifier>sources</classifier>
+ <outputDirectory>
+ ${project.build.directory}/sources
+ </outputDirectory>
+ </artifactItem>
+ </artifactItems>
+ </configuration>
+ </execution>
                 </executions>
                 <configuration>
                     <artifactItems>
@@ -132,6 +154,50 @@
                     </archive>
                 </configuration>
             </plugin>
+
+ <!--
+ Tell the source plugin about the sources downloaded by the
+ maven-dependency-plugin.
+ -->
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>add-source</id>
+ <phase>package</phase>
+ <goals>
+ <goal>add-source</goal>
+ </goals>
+ <configuration>
+ <sources>
+ <source>
+ ${project.build.directory}/sources
+ </source>
+ </sources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <!--
+ Configure the source plugin here so that it will know about
+ the sources downloaded by the maven-dependency-plugin and
+ configured by the build-helper-maven-plugin.
+ -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-source-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>attach-sources</id>
+ <goals>
+ <goal>jar</goal>
+ <goal>jar-no-fork</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
         </plugins>
     </build>
 </project>

diff -r 96d2f2d6dfa9 -r 5a6324983177 parent-distrib/pom.xml
--- a/parent-distrib/pom.xml Tue May 24 14:27:49 2011 -0700
+++ b/parent-distrib/pom.xml Tue May 24 14:29:18 2011 -0700
@@ -62,12 +62,34 @@
                 <artifactId>maven-dependency-plugin</artifactId>
                 <executions>
                     <execution>
- <id>unpack</id>
+ <!-- download the binaries -->
+ <id>get-binaries</id>
                         <phase>process-sources</phase>
                         <goals>
                             <goal>unpack</goal>
                         </goals>
                     </execution>
+ <execution>
+ <!-- download the sources -->
+ <id>get-sources</id>
+ <phase>process-sources</phase>
+ <goals>
+ <goal>unpack</goal>
+ </goals>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>com.sun.mail</groupId>
+ <artifactId>javax.mail</artifactId>
+ <version>${mail.version}</version>
+ <classifier>sources</classifier>
+ <outputDirectory>
+ ${project.build.directory}/sources
+ </outputDirectory>
+ </artifactItem>
+ </artifactItems>
+ </configuration>
+ </execution>
                 </executions>
                 <configuration>
                     <artifactItems>
@@ -87,6 +109,50 @@
                     </includes>
                 </configuration>
             </plugin>
+
+ <!--
+ Tell the source plugin about the sources downloaded by the
+ maven-dependency-plugin.
+ -->
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>add-source</id>
+ <phase>package</phase>
+ <goals>
+ <goal>add-source</goal>
+ </goals>
+ <configuration>
+ <sources>
+ <source>
+ ${project.build.directory}/sources
+ </source>
+ </sources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <!--
+ Configure the source plugin here so that it will know about
+ the sources downloaded by the maven-dependency-plugin and
+ configured by the build-helper-maven-plugin.
+ -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-source-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>attach-sources</id>
+ <goals>
+ <goal>jar</goal>
+ <goal>jar-no-fork</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
         </plugins>
     </build>
 </project>

diff -r 96d2f2d6dfa9 -r 5a6324983177 pom.xml
--- a/pom.xml Tue May 24 14:27:49 2011 -0700
+++ b/pom.xml Tue May 24 14:29:18 2011 -0700
@@ -487,6 +487,17 @@
                     <artifactId>maven-bundle-plugin</artifactId>
                     <version>2.1.0</version>
                 </plugin>
+ <plugin>
+ <!--
+ Configure the source plugin to include the pom.xml.
+ -->
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-source-plugin</artifactId>
+ <version>2.1.2</version>
+ <configuration>
+ <includePom>true</includePom>
+ </configuration>
+ </plugin>
             </plugins>
         </pluginManagement>
 


diff -r 5a6324983177 -r 5d7876f89658 mailapi/pom.xml
--- a/mailapi/pom.xml Tue May 24 14:29:18 2011 -0700
+++ b/mailapi/pom.xml Wed May 25 17:14:48 2011 -0700
@@ -144,50 +144,6 @@
                     </archive>
                 </configuration>
             </plugin>
-
- <!--
- Tell the source plugin about the sources downloaded by the
- maven-dependency-plugin.
- -->
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>build-helper-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>add-source</id>
- <phase>package</phase>
- <goals>
- <goal>add-source</goal>
- </goals>
- <configuration>
- <sources>
- <source>
- ${project.build.directory}/sources
- </source>
- </sources>
- </configuration>
- </execution>
- </executions>
- </plugin>
-
- <!--
- Configure the source plugin here so that it will know about
- the sources downloaded by the maven-dependency-plugin and
- configured by the build-helper-maven-plugin.
- -->
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-source-plugin</artifactId>
- <executions>
- <execution>
- <id>attach-sources</id>
- <goals>
- <goal>jar</goal>
- <goal>jar-no-fork</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
         </plugins>
     </build>
 </project>

diff -r 5a6324983177 -r 5d7876f89658 mailapijar/pom.xml
--- a/mailapijar/pom.xml Tue May 24 14:29:18 2011 -0700
+++ b/mailapijar/pom.xml Wed May 25 17:14:48 2011 -0700
@@ -135,50 +135,6 @@
                     </archive>
                 </configuration>
             </plugin>
-
- <!--
- Tell the source plugin about the sources downloaded by the
- maven-dependency-plugin.
- -->
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>build-helper-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>add-source</id>
- <phase>package</phase>
- <goals>
- <goal>add-source</goal>
- </goals>
- <configuration>
- <sources>
- <source>
- ${project.build.directory}/sources
- </source>
- </sources>
- </configuration>
- </execution>
- </executions>
- </plugin>
-
- <!--
- Configure the source plugin here so that it will know about
- the sources downloaded by the maven-dependency-plugin and
- configured by the build-helper-maven-plugin.
- -->
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-source-plugin</artifactId>
- <executions>
- <execution>
- <id>attach-sources</id>
- <goals>
- <goal>jar</goal>
- <goal>jar-no-fork</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
         </plugins>
     </build>
 </project>

diff -r 5a6324983177 -r 5d7876f89658 oldmail/pom.xml
--- a/oldmail/pom.xml Tue May 24 14:29:18 2011 -0700
+++ b/oldmail/pom.xml Wed May 25 17:14:48 2011 -0700
@@ -154,50 +154,6 @@
                     </archive>
                 </configuration>
             </plugin>
-
- <!--
- Tell the source plugin about the sources downloaded by the
- maven-dependency-plugin.
- -->
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>build-helper-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>add-source</id>
- <phase>package</phase>
- <goals>
- <goal>add-source</goal>
- </goals>
- <configuration>
- <sources>
- <source>
- ${project.build.directory}/sources
- </source>
- </sources>
- </configuration>
- </execution>
- </executions>
- </plugin>
-
- <!--
- Configure the source plugin here so that it will know about
- the sources downloaded by the maven-dependency-plugin and
- configured by the build-helper-maven-plugin.
- -->
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-source-plugin</artifactId>
- <executions>
- <execution>
- <id>attach-sources</id>
- <goals>
- <goal>jar</goal>
- <goal>jar-no-fork</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
         </plugins>
     </build>
 </project>

diff -r 5a6324983177 -r 5d7876f89658 parent-distrib/pom.xml
--- a/parent-distrib/pom.xml Tue May 24 14:29:18 2011 -0700
+++ b/parent-distrib/pom.xml Wed May 25 17:14:48 2011 -0700
@@ -109,50 +109,6 @@
                     </includes>
                 </configuration>
             </plugin>
-
- <!--
- Tell the source plugin about the sources downloaded by the
- maven-dependency-plugin.
- -->
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>build-helper-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>add-source</id>
- <phase>package</phase>
- <goals>
- <goal>add-source</goal>
- </goals>
- <configuration>
- <sources>
- <source>
- ${project.build.directory}/sources
- </source>
- </sources>
- </configuration>
- </execution>
- </executions>
- </plugin>
-
- <!--
- Configure the source plugin here so that it will know about
- the sources downloaded by the maven-dependency-plugin and
- configured by the build-helper-maven-plugin.
- -->
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-source-plugin</artifactId>
- <executions>
- <execution>
- <id>attach-sources</id>
- <goals>
- <goal>jar</goal>
- <goal>jar-no-fork</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
         </plugins>
     </build>
 </project>

diff -r 5a6324983177 -r 5d7876f89658 pom.xml
--- a/pom.xml Tue May 24 14:29:18 2011 -0700
+++ b/pom.xml Wed May 25 17:14:48 2011 -0700
@@ -415,6 +415,53 @@
             </plugin>
 
             <!--
+ Tell the source plugin about the sources that may have
+ been downloaded by the maven-dependency-plugin.
+ -->
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>add-source</id>
+ <phase>package</phase>
+ <goals>
+ <goal>add-source</goal>
+ </goals>
+ <configuration>
+ <sources>
+ <source>
+ ${project.build.directory}/sources
+ </source>
+ </sources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <!--
+ Configure the source plugin here so that it will know
+ about the sources that may have been downloaded by the
+ maven-dependency-plugin and configured by the
+ build-helper-maven-plugin.
+ -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-source-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>attach-sources</id>
+ <goals>
+ <goal>jar-no-fork</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <includePom>true</includePom>
+ </configuration>
+ </plugin>
+
+ <!--
                 This is the rule that creates the zip file for distribution.
             -->
             <plugin>
@@ -488,15 +535,9 @@
                     <version>2.1.0</version>
                 </plugin>
                 <plugin>
- <!--
- Configure the source plugin to include the pom.xml.
- -->
                     <groupId>org.apache.maven.plugins</groupId>
                     <artifactId>maven-source-plugin</artifactId>
                     <version>2.1.2</version>
- <configuration>
- <includePom>true</includePom>
- </configuration>
                  </plugin>
             </plugins>
         </pluginManagement>


diff -r 5d7876f89658 -r ea855fec9cb3 mail/src/main/java/com/sun/mail/util/logging/LogManagerProperties.java
--- a/mail/src/main/java/com/sun/mail/util/logging/LogManagerProperties.java Wed May 25 17:14:48 2011 -0700
+++ b/mail/src/main/java/com/sun/mail/util/logging/LogManagerProperties.java Mon Jun 13 16:42:02 2011 -0700
@@ -1,8 +1,8 @@
 /*
  * 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-2010 Jason Mehrens. All rights reserved.
+ * Copyright (c) 2009-2011 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009-2011 Jason Mehrens. 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
@@ -38,7 +38,6 @@
  * only if the new code is made subject to such option by the copyright
  * holder.
  */
-
 package com.sun.mail.util.logging;
 
 import java.io.ObjectStreamException;
@@ -151,15 +150,14 @@
     }
 
     /**
- * Clones the default properties.
- * @return the clone.
+ * Returns a properties object that contains a snapshot of the current
+ * state. This method violates the clone contract so that no instances
+ * of LogManagerProperties is exported for public use.
+ * @return the snapshot.
+ * @since JavaMail 1.4.4
      */
- public Object clone() {
- Properties parent;
- synchronized (this) {
- parent = defaults;
- }
- return parent.clone();
+ public synchronized Object clone() {
+ return exportCopy(defaults);
     }
 
     /**
@@ -246,12 +244,27 @@
     }
 
     /**
+ * Creates a public snapshot of this properties object using
+ * the given parent properties.
+ * @param parent the defaults to use with the snapshot.
+ * @return the safe snapshot.
+ */
+ private Properties exportCopy(final Properties parent) {
+ Thread.holdsLock(this);
+ final Properties child = new Properties(parent);
+ child.putAll(this);
+ return child;
+ }
+
+ /**
      * It is assumed that this method will never be called.
+ * We return a safe copy for export to avoid locking this properties
+ * object or the defaults during write.
      * @return the parent properties.
      * @throws ObjectStreamException if there is a problem.
      */
     private synchronized Object writeReplace() throws ObjectStreamException {
         assert false;
- return new Properties(defaults);
+ return exportCopy((Properties) defaults.clone());
     }
 }

diff -r 5d7876f89658 -r ea855fec9cb3 mail/src/main/java/com/sun/mail/util/logging/MailHandler.java
--- a/mail/src/main/java/com/sun/mail/util/logging/MailHandler.java Wed May 25 17:14:48 2011 -0700
+++ b/mail/src/main/java/com/sun/mail/util/logging/MailHandler.java Mon Jun 13 16:42:02 2011 -0700
@@ -1,8 +1,8 @@
 /*
  * 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-2010 Jason Mehrens. All rights reserved.
+ * Copyright (c) 2009-2011 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009-2011 Jason Mehrens. All rights reserved.
  *
  * The contents of this file are subject to the terms of either the GNU
  * General Public License Version 2 only ("GPL") or the Common Development
@@ -469,9 +469,24 @@
          */
         if (isLoggable(record)) {
             record.getSourceMethodName(); //infer caller, outside of lock
- MessageContext ctx;
- boolean priority;
- synchronized (this) {
+ publish0(record);
+ }
+ }
+
+ /**
+ * Performs the publish after the record has been filtered.
+ * @param record the record.
+ * @since JavaMail 1.4.5
+ */
+ private void publish0(final LogRecord record) {
+ MessageContext ctx;
+ boolean priority;
+ synchronized (this) {
+ if (size == data.length && size < capacity) {
+ grow();
+ }
+
+ if (size < data.length) {
                 data[size] = record;
                 ++size; //be nice to client compiler.
                 priority = isPushable(record);
@@ -479,16 +494,38 @@
                     ctx = writeLogRecords(ErrorManager.WRITE_FAILURE);
                 } else {
                     ctx = null;
- if (data.length == size) {
- grow();
- }
                 }
- }
-
- if (ctx != null) {
- send(ctx, priority, ErrorManager.WRITE_FAILURE);
+ } else { //drain the buffer and try again.
+ priority = false;
+ ctx = flushAndRePublish(record);
             }
         }
+
+ if (ctx != null) {
+ send(ctx, priority, ErrorManager.WRITE_FAILURE);
+ }
+ }
+
+ /**
+ * Flushes the buffer into a MessageContext and then tries to store
+ * the given record. This method will only be called in cases of
+ * reentrant filters, formatters, or comparators. The push filter is
+ * the only filter allowed to be reentrant. This is because it is never
+ * used during formatting and only called after a record is stored.
+ * @param record the log record still needed to publish.
+ * @return the MessageContext or null.
+ * @since JavaMail 1.4.5
+ */
+ private MessageContext flushAndRePublish(final LogRecord record) {
+ MessageContext ctx = writeLogRecords(ErrorManager.WRITE_FAILURE);
+ if (ctx != null) {
+ publish0(record);
+ } else { //Use ISE because this is a push inside of a push.
+ reportError("Unable to drain buffer.",
+ new IllegalStateException(),
+ ErrorManager.WRITE_FAILURE);
+ }
+ return ctx;
     }
 
     /**
@@ -529,9 +566,7 @@
         synchronized (this) {
             super.setLevel(Level.OFF); //security check first.
             try {
- if (size > 0) {
- ctx = writeLogRecords(ErrorManager.CLOSE_FAILURE);
- }
+ ctx = writeLogRecords(ErrorManager.CLOSE_FAILURE);
             } finally {
                 /**
                  * The sign bit of the capacity is set to ensure that records
@@ -690,7 +725,7 @@
         checkAccess();
 
         Session settings;
- synchronized(this) {
+ synchronized (this) {
             if (isWriting) {
                 throw new IllegalStateException();
             }
@@ -1026,7 +1061,7 @@
      */
     final String contentTypeOf(String head) {
         if (head != null && head.length() > 0) {
- final int MAX_CHARS = 15;
+ final int MAX_CHARS = 25;
             if (head.length() > MAX_CHARS) {
                 head = head.substring(0, MAX_CHARS);
             }
@@ -1048,6 +1083,24 @@
     }
 
     /**
+ * Converts a mime message to a raw string or formats the reason
+ * why message can't be changed to raw string and reports it.
+ * @param msg the mime message.
+ * @param ex the original exception.
+ * @param code the ErrorManager code.
+ * @since JavaMail 1.4.5
+ */
+ private void reportError(Message msg, Exception ex, int code) {
+ try { //use super call so we do not prefix raw email.
+ super.reportError(toRawString(msg), ex, code);
+ } catch (final MessagingException rawMe) {
+ reportError(toMsgString(rawMe), ex, code);
+ } catch (final IOException rawIo) {
+ reportError(toMsgString(rawIo), ex, code);
+ }
+ }
+
+ /**
      * Determines the mimeType from the given file name.
      * Used to override the body content type and used for all attachments.
      * @param name the file name or class name.
@@ -1069,7 +1122,7 @@
      * @param type the mime type.
      * @throws MessagingException if there is a problem.
      */
- private void setContent(MimeBodyPart part, StringBuffer buf, String type) throws MessagingException {
+ private void setContent(MimeBodyPart part, CharSequence buf, String type) throws MessagingException {
         final String encoding = getEncoding();
         if (type != null && !"text/plain".equals(type)) {
             if (encoding == null) {
@@ -1245,7 +1298,11 @@
      */
     private void reset() {
         assert Thread.holdsLock(this);
- Arrays.fill(data, 0, size, null);
+ if (size < data.length) {
+ Arrays.fill(data, 0, size, null);
+ } else {
+ Arrays.fill(data, null);
+ }
         this.size = 0;
     }
 
@@ -1263,7 +1320,6 @@
         this.data = (LogRecord[]) copyOf(data, newCapacity);
     }
 
-
     /**
      * Configures the handler properties from the log manager.
      * @throws SecurityException if a security manager exists and the
@@ -1566,13 +1622,7 @@
      * @param code the error manager code.
      */
     private void push(final boolean priority, final int code) {
- MessageContext ctx = null;
- synchronized (this) {
- if (size > 0) {
- ctx = writeLogRecords(code);
- }
- }
-
+ MessageContext ctx = writeLogRecords(code);
         if (ctx != null) {
             send(ctx, priority, code);
         }
@@ -1593,13 +1643,7 @@
             envelopeFor(ctx, priority);
             Transport.send(msg);
         } catch (final Exception E) {
- try { //use super call so we do not prefix raw email.
- super.reportError(toRawString(msg), E, code);
- } catch (final MessagingException rawMe) {
- reportError(toMsgString(rawMe), E, code);
- } catch (final IOException rawIo) {
- reportError(toMsgString(rawIo), E, code);
- }
+ reportError(msg, E, code);
         }
     }
 
@@ -1629,13 +1673,11 @@
      * attached session.
      */
     private synchronized MessageContext writeLogRecords(final int code) {
- assert size > 0;
-
- if (isWriting) {
+ if (size == 0 || isWriting) {
             return null;
         }
 
- final MimeMessage msg;
+ MimeMessage msg = null;
         isWriting = true;
         try {
             msg = new MimeMessage(session);
@@ -1801,7 +1843,11 @@
 
         //Perform all of the copy actions first.
         final MimeMessage abort = new MimeMessage(session);
- envelopeFor(new MessageContext(abort), true);
+ synchronized (this) { //create the subject.
+ appendSubject(abort, head(this.subjectFormatter));
+ appendSubject(abort, tail(this.subjectFormatter, ""));
+ }
+ envelopeFor(new MessageContext(abort), true); //calls saveChanges.
 
         String msg;
         if (InternetAddress.getLocalAddress(session) == null) {
@@ -1811,6 +1857,7 @@
         }
 
         try {
+ //Ensure transport provider is installed.
             Address[] all = abort.getAllRecipients();
             Transport t;
             try {
@@ -1819,7 +1866,7 @@
                     session.getProperty("mail.transport.protocol"); //force copy
                 } else {
                     MessagingException me =
- new MessagingException("No recipient addresses.");
+ new MessagingException("No recipient addresses.");
                     reportError(msg, me, ErrorManager.OPEN_FAILURE);
                     throw me;
                 }
@@ -1836,13 +1883,14 @@
                 t.connect();
                 try {
                     /**
- * An empty message will fail at message writeTo.
+ * A message without content will fail at message writeTo.
                      * This allows the handler to capture all mail properties.
                      */
                     t.sendMessage(abort, all);
- reportError(msg, new MessagingException(
- "An empty message was sent."),
- ErrorManager.WRITE_FAILURE);
+ final MessagingException write = new MessagingException(
+ "An empty message was sent.");
+ fixUpContent(abort, verify, write);
+ reportError(abort, write, ErrorManager.WRITE_FAILURE);
                 } catch (MessagingException expectNoContent) {
                 } finally {
                     t.close();
@@ -1869,7 +1917,8 @@
                     }
                 }
             }
-
+
+ //The null and zero length case is handled getting the transport.
             if (all != null) {
                 for (int i = 0; i < all.length; ++i) {
                     Address a = all[i];
@@ -1890,9 +1939,40 @@
                 }
             }
         } catch (final MessagingException ME) {
- reportError(msg, ME, ErrorManager.OPEN_FAILURE);
+ fixUpContent(abort, verify, ME);
+ reportError(abort, ME, ErrorManager.OPEN_FAILURE);
         } catch (final RuntimeException RE) {
- reportError(msg, RE, ErrorManager.OPEN_FAILURE);
+ fixUpContent(abort, verify, RE);
+ reportError(abort, RE, ErrorManager.OPEN_FAILURE);
+ }
+ }
+
+ /**
+ * Creates and sets the message content from the given Throwable.
+ * When verify fails, this method fixes the 'abort' message so that any
+ * created envelope data can be used in the error manager.
+ * @param msg the message with or without content.
+ * @param verify the verify enum.
+ * @param t the throwable or null.
+ * @since JavaMail 1.4.5
+ */
+ private void fixUpContent(MimeMessage msg, String verify, Throwable t) {
+ try { //add content so toRawString doesn't fail.
+ final MimeMultipart multipart = new MimeMultipart();
+ final MimeBodyPart body = new MimeBodyPart();
+ body.setDisposition(Part.INLINE);
+ body.setDescription("Formatted using "
+ + (t == null ? Throwable.class.getName()
+ : t.getClass().getName()) + " and filtered with "
+ + verify + '.');
+ setContent(body, toMsgString(t), "text/plain");
+ multipart.addBodyPart(body);
+ msg.setContent(multipart);
+ msg.saveChanges();
+ } catch (final MessagingException ME) {
+ reportError("Unable to create body.", ME, ErrorManager.OPEN_FAILURE);
+ } catch (final RuntimeException RE) {
+ reportError("Unable to create body.", RE, ErrorManager.OPEN_FAILURE);
         }
     }
 
@@ -2027,8 +2107,8 @@
         try {
             final String old = msg.getSubject();
             assert msg instanceof MimeMessage;
- ((MimeMessage) msg).setSubject(old != null ?
- old.concat(chunk) : chunk, getEncoding());
+ ((MimeMessage) msg).setSubject(old != null
+ ? old.concat(chunk) : chunk, getEncoding());
         } catch (final MessagingException ME) {
             reportError(ME.getMessage(), ME, ErrorManager.FORMAT_FAILURE);
         }
@@ -2203,15 +2283,20 @@
     /**
      * Converts a throwable to a message string. This method is called when
      * Message.writeTo throws an exception.
- * @param t any throwable.
- * @return the throwable with a stack trace.
+ * @param t any throwable or null.
+ * @return the throwable with a stack trace or the literal null.
      */
     private String toMsgString(final Throwable t) {
+ if (t == null) {
+ return "null";
+ }
+
         final ByteArrayOutputStream out = new ByteArrayOutputStream(1024);
         final PrintStream ps = new PrintStream(out);
         ps.println(t.getMessage());
         t.printStackTrace(ps);
         ps.flush();
+ ps.close(); //BUG ID 6995537
         return out.toString();
     }
 

diff -r 5d7876f89658 -r ea855fec9cb3 mail/src/test/java/com/sun/mail/util/logging/LogManagerPropertiesTest.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mail/src/test/java/com/sun/mail/util/logging/LogManagerPropertiesTest.java Mon Jun 13 16:42:02 2011 -0700
@@ -0,0 +1,141 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2009-2011 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009-2011 Jason Mehrens. 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.util.logging;
+
+import java.io.*;
+import java.util.logging.*;
+import java.util.*;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ * Test case for the LogManagerProperties spec.
+ * @author Jason Mehrens
+ */
+public class LogManagerPropertiesTest {
+
+ @Test
+ public void testClone() throws Exception {
+ String prefix = LogManagerPropertiesTest.class.getName();
+ Properties parent;
+ LogManagerProperties mp;
+ LogManager manager = LogManager.getLogManager();
+ try {
+ String key = prefix.concat(".dummy");
+ parent = new Properties();
+ parent.put(key, "value");
+
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ parent.store(out, "No comment");
+ manager.readConfiguration(new ByteArrayInputStream(out.toByteArray()));
+
+ parent = new Properties();
+ mp = new LogManagerProperties(parent, prefix);
+
+ assertNull(mp.get(key));
+ assertEquals("value", mp.getProperty(key));
+ assertEquals("value", mp.get(key)); //ensure copy worked.
+ } finally {
+ manager.reset();
+ }
+
+ Properties clone = (Properties) mp.clone();
+ assertFalse(clone instanceof LogManagerProperties);
+ assertEquals(Properties.class, clone.getClass());
+ assertNotSame(clone, parent);
+ assertNotSame(clone, mp);
+ assertEquals(mp.size(), clone.size());
+ assertTrue(clone.equals(mp)); //don't call mp.equals.
+ }
+
+ @Test
+ public void testGetProperty_String() throws Exception {
+ String prefix = LogManagerPropertiesTest.class.getName();
+ LogManager manager = LogManager.getLogManager();
+ try {
+ String key = prefix.concat(".dummy");
+ Properties parent = new Properties();
+ parent.put(key, "value");
+
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ parent.store(out, "No comment");
+ manager.readConfiguration(new ByteArrayInputStream(out.toByteArray()));
+
+ parent = new Properties();
+ LogManagerProperties mp = new LogManagerProperties(parent, prefix);
+
+ assertNull(mp.get(key));
+ assertEquals("value", mp.getProperty(key));
+ assertEquals("value", mp.get(key)); //ensure copy worked.
+ parent.put(key, "newValue");
+ assertEquals("newValue", mp.getProperty(key));
+ } finally {
+ manager.reset();
+ }
+ }
+
+ @Test
+ public void testGetProperty_String_String() throws Exception {
+ String prefix = LogManagerPropertiesTest.class.getName();
+ LogManager manager = LogManager.getLogManager();
+ try {
+ String key = prefix.concat(".dummy");
+ Properties parent = new Properties();
+ parent.put(key, "value");
+
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ parent.store(out, "No comment");
+ manager.readConfiguration(new ByteArrayInputStream(out.toByteArray()));
+
+ parent = new Properties();
+ LogManagerProperties mp = new LogManagerProperties(parent, prefix);
+
+ assertNull(mp.get(key));
+ assertEquals("value", mp.getProperty(key, null));
+ assertEquals("value", mp.get(key)); //ensure copy worked.
+ parent.put(key, "newValue");
+ assertEquals("newValue", mp.getProperty(key, null));
+ assertEquals("default", mp.getProperty("unknown", "default"));
+ } finally {
+ manager.reset();
+ }
+ }
+}

diff -r 5d7876f89658 -r ea855fec9cb3 mail/src/test/java/com/sun/mail/util/logging/MailHandlerTest.java
--- a/mail/src/test/java/com/sun/mail/util/logging/MailHandlerTest.java Wed May 25 17:14:48 2011 -0700
+++ b/mail/src/test/java/com/sun/mail/util/logging/MailHandlerTest.java Mon Jun 13 16:42:02 2011 -0700
@@ -1,8 +1,8 @@
 /*
  * 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-2010 Jason Mehrens. All rights reserved.
+ * Copyright (c) 2009-2011 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009-2011 Jason Mehrens. 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
@@ -49,6 +49,7 @@
 import java.util.ArrayList;
 import java.util.Comparator;
 import java.util.List;
+import java.util.Locale;
 import java.util.Properties;
 import java.util.Random;
 import java.util.logging.*;
@@ -192,8 +193,8 @@
         assertEquals(em.exceptions.isEmpty(), true);
         instance.close();
 
+ assertEquals(true, em.exceptions.get(0) instanceof MessagingException);
         assertEquals(1, em.exceptions.size());
- assertEquals(true, em.exceptions.get(0) instanceof MessagingException);
 
         //Test for valid message.
         instance = createHandlerWithRecords();
@@ -594,7 +595,7 @@
         props.setProperty("mail.to", "localhost_at_localdomain");
         instance.setMailProperties(props);
 
- MessageErrorManager empty = new MessageErrorManager(instance) {
+ MessageErrorManager empty = new MessageErrorManager(instance.getMailProperties()) {
 
             @Override
             public void error(MimeMessage msg, Throwable t, int code) {
@@ -616,7 +617,7 @@
         final String enc = "iso-8859-1";
         LogManager manager = LogManager.getLogManager();
         final MailHandler instance = new MailHandler();
- MessageErrorManager em = new MessageErrorManager(instance) {
+ MessageErrorManager em = new MessageErrorManager(instance.getMailProperties()) {
 
             protected void error(MimeMessage msg, Throwable t, int code) {
                 try {
@@ -1220,7 +1221,7 @@
         props.put(p.concat(".mail.smtp.port"), Integer.toString(OPEN_PORT));
         props.put(p.concat(".mail.to"), "localhost_at_localdomain");
         props.put(p.concat(".mail.cc"), "localhost_at_localdomain");
- props.put(p.concat(".mail.subject"), p.concat(" test"));
+ props.put(p.concat(".subject"), p.concat(" test"));
         props.put(p.concat(".mail.from"), "localhost_at_localdomain");
         props.put(p.concat(".errorManager"), InternalErrorManager.class.getName());
         if (verify != null) {
@@ -1238,7 +1239,7 @@
         assertNotNull(manager.getProperty(p.concat(".mail.smtp.port")));
         assertNotNull(manager.getProperty(p.concat(".mail.to")));
         assertNotNull(manager.getProperty(p.concat(".mail.cc")));
- assertNotNull(manager.getProperty(p.concat(".mail.subject")));
+ assertNotNull(manager.getProperty(p.concat(".subject")));
         assertNotNull(manager.getProperty(p.concat(".mail.from")));
         assertEquals(verify, manager.getProperty(p.concat(".verify")));
         assertNotNull(manager.getProperty(p.concat(".mail.smtp.connectiontimeout")));
@@ -1404,7 +1405,7 @@
         final String[] value = new String[1];
         MailHandler instance = new MailHandler();
         instance.setEncoding("us-ascii");
- MessageErrorManager em = new MessageErrorManager(instance) {
+ MessageErrorManager em = new MessageErrorManager(instance.getMailProperties()) {
 
             protected void error(MimeMessage msg, Throwable t, int code) {
                 try {
@@ -2008,6 +2009,90 @@
     }
 
     @Test
+ public void testFilterReentrance() {
+ Logger logger = Logger.getLogger("testFilterReentrance");
+
+ MailHandler instance = new MailHandler(2);
+ InternalErrorManager em = new InternalErrorManager();
+ instance.setErrorManager(em);
+ instance.setFilter(new ReentranceFilter());
+
+ logger.setUseParentHandlers(false);
+ logger.setLevel(Level.ALL);
+ logger.addHandler(instance);
+ hardRef = logger;
+ try {
+ assertNotNull(hardRef);
+ logger.logp(Level.SEVERE, MailHandlerTest.class.getName(), "testFilterReentrance", "test");
+
+ int seenIse = 0;
+ for (int i = 0; i < em.exceptions.size(); i++) {
+ if (em.exceptions.get(i) instanceof MessagingException) {
+ continue;
+ } else if (em.exceptions.get(i) instanceof IllegalStateException) {
+ seenIse++;
+ continue; //expected.
+ } else {
+ fail(String.valueOf(em.exceptions.get(i)));
+ }
+ }
+
+ assertTrue("No IllegalStateException", seenIse > 0);
+ } finally {
+ logger.removeHandler(instance);
+ logger.setLevel(null);
+ logger.setUseParentHandlers(true);
+ hardRef = null;
+ }
+ }
+
+ @Test
+ public void testPushFilterReentrance() {
+ testPushFilterReentrance(1, 1);
+ testPushFilterReentrance(1, 2);
+ testPushFilterReentrance(1, 1000);
+ testPushFilterReentrance(500, 1000);
+ testPushFilterReentrance(1000, 1000);
+ }
+
+ private void testPushFilterReentrance(int records, int cap) {
+ assert records <= cap : records;
+ Logger logger = Logger.getLogger("testPushFilterReentrance");
+
+ MailHandler instance = new MailHandler(cap);
+ InternalErrorManager em = new InternalErrorManager();
+ instance.setErrorManager(em);
+ instance.setPushLevel(Level.ALL);
+ instance.setPushFilter(new ReentranceFilter());
+
+
+ logger.setUseParentHandlers(false);
+ logger.setLevel(Level.ALL);
+ logger.addHandler(instance);
+ hardRef = logger;
+ try {
+ assertNotNull(hardRef);
+
+ while (records-- > 0) {
+ logger.logp(Level.SEVERE, MailHandlerTest.class.getName(), "testPushFilterReentrance", "test");
+ }
+ instance.close();
+
+ for (int i = 0; i < em.exceptions.size(); i++) {
+ if (em.exceptions.get(i) instanceof MessagingException == false) {
+ fail(String.valueOf(em.exceptions.get(i)));
+ }
+ }
+ assertFalse(em.exceptions.isEmpty());
+ } finally {
+ logger.removeHandler(instance);
+ logger.setLevel(
[truncated due to length]