commits@javamail.java.net

[javamail~mercurial:649] fix NullPointerExceptions in InternetAddress - bug 6368

From: <shannon_at_java.net>
Date: Mon, 21 Apr 2014 19:00:34 +0000

Project: javamail
Repository: mercurial
Revision: 649
Author: shannon
Date: 2014-04-19 00:14:19 UTC
Link:

Log Message:
------------
add a more specific exception message for a Domino server bug
Added missing license headers.
CompactFormatter use LogManager default over null pointer.
CompactFormatter added fallbacks for isReflection and isStaticUtility.
LogManagerProperties fail late on bad classname.
Improve test coverage.

(From Jason)
fix broken equals method in URLName and NewsAddress - bug 6365
CompactFormatter improve javadocs.
CollectorFormatter fix incorrect defaults in javadocs.
CollectorFormatter treat empty comparator string as null.

(From Jason)
fill NullPointerException in ContentType.match - bug 6366
fix hash codes for ModifiedSinceTerm, YoungerTerm, OlderTerm - bug 6367
fix NullPointerExceptions in InternetAddress - bug 6368


Revisions:
----------
643
644
645
646
647
648
649


Modified Paths:
---------------
mail/src/main/java/com/sun/mail/imap/protocol/BODYSTRUCTURE.java
mail/src/main/java/com/sun/mail/util/logging/CollectorFormatter.java
mail/src/main/java/com/sun/mail/util/logging/CompactFormatter.java
mail/src/main/java/com/sun/mail/util/logging/LogManagerProperties.java
mail/src/test/java/com/sun/mail/util/logging/CollectorFormatterTest.java
mail/src/test/java/com/sun/mail/util/logging/CompactFormatterTest.java
mail/src/test/java/com/sun/mail/util/logging/LogManagerPropertiesTest.java
doc/release/CHANGES.txt
mail/src/main/java/javax/mail/URLName.java
mail/src/main/java/javax/mail/internet/NewsAddress.java
mail/src/main/java/javax/mail/internet/ContentType.java
mail/src/main/java/com/sun/mail/imap/ModifiedSinceTerm.java
mail/src/main/java/com/sun/mail/imap/OlderTerm.java
mail/src/main/java/com/sun/mail/imap/YoungerTerm.java
mail/src/main/java/javax/mail/internet/InternetAddress.java


Added Paths:
------------
mail/src/test/java/javax/mail/URLNameTest.java
mail/src/test/java/javax/mail/internet/NewsAddressTest.java
mail/src/test/java/javax/mail/internet/ContentTypeTest.java


Diffs:
------
diff -r e2f27fa27b62 -r bbe7502b3488 mail/src/main/java/com/sun/mail/imap/protocol/BODYSTRUCTURE.java
--- a/mail/src/main/java/com/sun/mail/imap/protocol/BODYSTRUCTURE.java Mon Apr 07 14:03:06 2014 -0700
+++ b/mail/src/main/java/com/sun/mail/imap/protocol/BODYSTRUCTURE.java Tue Apr 15 15:32:02 2014 -0700
@@ -1,7 +1,7 @@
 /*
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
  *
- * Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2014 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
@@ -204,8 +204,28 @@
             // Throw away any further extension data
             while (r.readByte() == ' ')
                 parseBodyExtension(r);
- }
- else { // Single part
+ } else if (r.peekByte() == ')') { // (illegal) empty body
+ /*
+ * Domino will fail to return the body structure of nested messages.
+ * Fake it by providing an empty message. Could probably do better
+ * with more work...
+ */
+ /*
+ * XXX - this prevents the exception, but without the exception
+ * the application has no way to know the data from the message
+ * is missing.
+ *
+ if (parseDebug)
+ System.out.println("DEBUG IMAP: empty body, fake it");
+ r.readByte();
+ type = "text";
+ subtype = "plain";
+ lines = 0;
+ size = 0;
+ */
+ throw new ParsingException(
+ "BODYSTRUCTURE parse error: missing body content");
+ } else { // Single part
             if (parseDebug)
                 System.out.println("DEBUG IMAP: single part");
             type = r.readString();


diff -r bbe7502b3488 -r 5680e2bef1d3 mail/src/main/java/com/sun/mail/util/logging/CollectorFormatter.java
--- a/mail/src/main/java/com/sun/mail/util/logging/CollectorFormatter.java Tue Apr 15 15:32:02 2014 -0700
+++ b/mail/src/main/java/com/sun/mail/util/logging/CollectorFormatter.java Tue Apr 15 15:34:32 2014 -0700
@@ -1,3 +1,43 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2013-2014 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013-2014 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.lang.reflect.UndeclaredThrowableException;
@@ -101,7 +141,7 @@
     /**
      * Creates the formatter using the given format.
      *
- * @param format the message format.
+ * @param format the message format or null to use the LogManager default.
      * @throws SecurityException if a security manager exists and the caller
      * does not have <tt>LoggingPermission("control")</tt>.
      * @throws UndeclaredThrowableException if there are problems when loading
@@ -119,9 +159,10 @@
      * Creates the formatter using the given values.
      *
      * @param format the format string.
- * @param f the formatter used on the collected log record or null.
+ * @param f the formatter used on the collected log record or null to use
+ * the LogManager default.
      * @param c the comparator used to determine which log record to format or
- * null.
+ * null to specify no comparator.
      * @throws SecurityException if a security manager exists and the caller
      * does not have <tt>LoggingPermission("control")</tt>.
      * @throws UndeclaredThrowableException if there are problems when loading
@@ -214,7 +255,8 @@
     }
 
     /**
- * Peeks at the current LogRecord and formats it.
+ * Formats the collected LogRecord and summary statistics. The LogRecord and
+ * summary statistics are not changed by calling this method.
      *
      * @return the current record formatted or the default toString.
      * @see #getTail(java.util.logging.Handler)
@@ -405,6 +447,7 @@
      *
      * @param p the class name prefix.
      * @return the formatter.
+ * @throws UndeclaredThrowableException if the formatter can not be created.
      */
     private Formatter initFormatter(final String p) {
         final LogManager m = LogManagerProperties.getLogManager();

diff -r bbe7502b3488 -r 5680e2bef1d3 mail/src/main/java/com/sun/mail/util/logging/CompactFormatter.java
--- a/mail/src/main/java/com/sun/mail/util/logging/CompactFormatter.java Tue Apr 15 15:32:02 2014 -0700
+++ b/mail/src/main/java/com/sun/mail/util/logging/CompactFormatter.java Tue Apr 15 15:34:32 2014 -0700
@@ -86,10 +86,8 @@
      * method.
      */
     public CompactFormatter(final String format) {
- if (format == null) {
- throw new NullPointerException();
- }
- this.fmt = format;
+ String p = getClass().getName();
+ this.fmt = format == null ? initFormat(p) : format;
     }
 
     /**
@@ -98,8 +96,8 @@
      * <ol start='0'>
      * <li>{_at_code format} - the {_at_link java.util.Formatter
      * java.util.Formatter} format string specified in the
- * {_at_code &lt;formatter-name&gt;.format} property or the format that was
- * given when this formatter was created.</li>
+ * &lt;formatter-name&gt;.format property or the format that was given when
+ * this formatter was created.</li>
      * <li>{_at_code date} - a {_at_link Date} object representing
      * {_at_linkplain LogRecord#getMillis event time} of the log record.</li>
      * <li>{_at_code source} - a string representing the caller, if available;
@@ -397,7 +395,9 @@
         } catch (Exception ignore) {
         } catch (LinkageError ignore) {
         }
- return false;
+ return (!s.getClassName().endsWith("es")
+ && s.getClassName().endsWith("s"))
+ || s.getClassName().contains("Util");
     }
 
     /**
@@ -437,7 +437,8 @@
         } catch (Exception ignore) {
         } catch (LinkageError ignore) {
         }
- return false;
+ return s.getClassName().startsWith("java.lang.reflect.")
+ || s.getClassName().startsWith("sun.reflect.");
     }
 
     /**

diff -r bbe7502b3488 -r 5680e2bef1d3 mail/src/main/java/com/sun/mail/util/logging/LogManagerProperties.java
--- a/mail/src/main/java/com/sun/mail/util/logging/LogManagerProperties.java Tue Apr 15 15:32:02 2014 -0700
+++ b/mail/src/main/java/com/sun/mail/util/logging/LogManagerProperties.java Tue Apr 15 15:34:32 2014 -0700
@@ -84,9 +84,9 @@
      */
     private static final LogManager LOG_MANAGER = LogManager.getLogManager();
     /**
- * Caches the read only reflection class names string array.
- * Declared volatile for safe publishing only. The
- * VO_VOLATILE_REFERENCE_TO_ARRAY warning is a false positive.
+ * Caches the read only reflection class names string array. Declared
+ * volatile for safe publishing only. The VO_VOLATILE_REFERENCE_TO_ARRAY
+ * warning is a false positive.
      */
     @SuppressWarnings("VolatileArrayField")
     private static volatile String[] REFLECT_NAMES;
@@ -337,25 +337,27 @@
      * @since JavaMail 1.5.2
      */
     static boolean isReflectionClass(String name) throws Exception {
- String[] names = String[].class.cast(REFLECT_NAMES);
- if (names == null) { //Benign data race.
- names = reflectionClassNames();
- REFLECT_NAMES = names;
+ String[] names;
+ if ((names = REFLECT_NAMES) == null) { //Benign data race.
+ REFLECT_NAMES = names = reflectionClassNames();
         }
 
         for (String rf : names) { //The set of names is small.
             if (name.equals(rf)) {
- return true;
+ return true;
             }
         }
+
+ findClass(name); //Fail late instead of normal return.
         return false;
     }
 
     /**
      * Determines all of the reflection class names used to invoke methods.
      *
- * This method performs indirect and direct calls on a throwable to
- * capture the standard class names and the implementation class names.
+ * This method performs indirect and direct calls on a throwable to capture
+ * the standard class names and the implementation class names.
+ *
      * @return a string array containing the fully qualified class names.
      * @throws Exception if there is a problem.
      */

diff -r bbe7502b3488 -r 5680e2bef1d3 mail/src/test/java/com/sun/mail/util/logging/CollectorFormatterTest.java
--- a/mail/src/test/java/com/sun/mail/util/logging/CollectorFormatterTest.java Tue Apr 15 15:32:02 2014 -0700
+++ b/mail/src/test/java/com/sun/mail/util/logging/CollectorFormatterTest.java Tue Apr 15 15:34:32 2014 -0700
@@ -1,3 +1,43 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2013-2014 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013-2014 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.ByteArrayInputStream;
@@ -116,12 +156,43 @@
     @Test
     public void testFormatNoRecords() {
         XMLFormatter xml = new XMLFormatter();
- CollectorFormatter f = new CollectorFormatter("{0}{1}{2}", xml,
+ CollectorFormatter f = new CollectorFormatter((String) null, xml,
                 (Comparator<LogRecord>) null);
 
         String result = f.getTail((Handler) null);
- String expect = f.getHead((Handler) null)
- + f.getTail((Handler) null);
+ String expect = f.finish(xml.getHead((Handler) null))
+ + f.finish(xml.getTail((Handler) null)) + '\n';
+ assertEquals(result, expect);
+ }
+
+ @Test
+ public void testFormatOneRecord() {
+ XMLFormatter xml = new XMLFormatter();
+ CollectorFormatter f = new CollectorFormatter((String) null, xml,
+ (Comparator<LogRecord>) null);
+ LogRecord record = new LogRecord(Level.SEVERE, "message");
+ assertEquals("", f.format(record));
+ String result = f.getTail((Handler) null);
+ String expect = f.finish(xml.getHead((Handler) null))
+ + f.finish(xml.format(record))
+ + f.finish(xml.getTail((Handler) null)) + '\n';
+ assertEquals(result, expect);
+ }
+
+ @Test
+ public void testFormatTwoRecords() {
+ XMLFormatter xml = new XMLFormatter();
+ CollectorFormatter f = new CollectorFormatter((String) null, xml,
+ (Comparator<LogRecord>) null);
+ LogRecord record = new LogRecord(Level.SEVERE, "first");
+ assertEquals("", f.format(record));
+
+ record = new LogRecord(Level.SEVERE, "second");
+ assertEquals("", f.format(record));
+ String result = f.getTail((Handler) null);
+ String expect = f.finish(xml.getHead((Handler) null))
+ + f.finish(xml.format(record))
+ + f.finish(xml.getTail((Handler) null)) + "... 1 more\n";
         assertEquals(result, expect);
     }
 
@@ -462,6 +533,27 @@
         }
     }
 
+ @Test
+ public void testFormatter() throws Exception {
+ final String p = CollectorFormatter.class.getName();
+ Properties props = new Properties();
+ props.put(p.concat(".formatter"), XMLFormatter.class.getName());
+ LogManager manager = LogManager.getLogManager();
+ try {
+ read(manager, props);
+ XMLFormatter xml = new XMLFormatter();
+ CollectorFormatter cf = new CollectorFormatter();
+ LogRecord first = new LogRecord(Level.SEVERE, Level.SEVERE.getName());
+ assertEquals("", cf.format(first));
+ String result = cf.getTail((Handler) null);
+ assertEquals(result, cf.finish(xml.getHead((Handler) null))
+ + cf.finish(xml.format(first))
+ + cf.finish(xml.getTail((Handler) null)) + '\n');
+ } finally {
+ manager.reset();
+ }
+ }
+
     private void read(LogManager manager, Properties props) throws IOException {
         ByteArrayOutputStream out = new ByteArrayOutputStream(512);
         props.store(out, CollectorFormatterTest.class.getName());

diff -r bbe7502b3488 -r 5680e2bef1d3 mail/src/test/java/com/sun/mail/util/logging/CompactFormatterTest.java
--- a/mail/src/test/java/com/sun/mail/util/logging/CompactFormatterTest.java Tue Apr 15 15:32:02 2014 -0700
+++ b/mail/src/test/java/com/sun/mail/util/logging/CompactFormatterTest.java Tue Apr 15 15:34:32 2014 -0700
@@ -1,3 +1,43 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2013-2014 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013-2014 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.ByteArrayInputStream;
@@ -75,10 +115,10 @@
         assertEquals(Level.SEVERE.getLocalizedName(), result);
     }
 
- @Test(expected = NullPointerException.class)
+ @Test
     public void testNewFormatterNullPattern() {
         CompactFormatter cf = new CompactFormatter((String) null);
- fail(cf.toString());
+ assertEquals(CompactFormatter.class, cf.getClass());
     }
 
     @Test
@@ -550,6 +590,33 @@
     }
 
     @Test
+ public void testIgnoreStaticUtilityClassUtilError() {
+ CompactFormatter cf = new CompactFormatter();
+ String n = getClass().getName().concat("MimeUtility");
+ String f = n.concat(".java");
+ StackTraceElement s = new StackTraceElement(n, "encodeText", f, 400);
+ assertTrue(s.toString(), cf.ignore(s));
+ }
+
+ @Test
+ public void testIgnoreStaticUtilityClassWithSError() {
+ CompactFormatter cf = new CompactFormatter();
+ String n = getClass().getName().concat("Collections");
+ String f = n.concat(".java");
+ StackTraceElement s = new StackTraceElement(n, "nCopies", f, 400);
+ assertTrue(s.toString(), cf.ignore(s));
+ }
+
+ @Test
+ public void testIgnoreStaticUtilityClassWithSeError() {
+ CompactFormatter cf = new CompactFormatter();
+ String n = getClass().getName().concat("Properties");
+ String f = n.concat(".java");
+ StackTraceElement s = new StackTraceElement(n, "get", f, 400);
+ assertFalse(s.toString(), cf.ignore(s));
+ }
+
+ @Test
     public void testIgnoreSyntheticMethod() {
         CompactFormatter cf = new CompactFormatter();
         String n = UNKNOWN_CLASS_NAME;
@@ -577,6 +644,24 @@
     }
 
     @Test
+ public void testIgnoreReflectMethodApiError() {
+ CompactFormatter cf = new CompactFormatter();
+ String n = "java.lang.reflect.".concat(getClass().getName());
+ String f = n.concat(".java");
+ StackTraceElement s = new StackTraceElement(n, "invoke", f, 10);
+ assertTrue(s.toString(), cf.ignore(s));
+ }
+
+ @Test
+ public void testIgnoreReflectMethodSunError() {
+ CompactFormatter cf = new CompactFormatter();
+ String n = "sun.reflect.".concat(getClass().getName());
+ String f = n.concat(".java");
+ StackTraceElement s = new StackTraceElement(n, "invoke", f, 10);
+ assertTrue(s.toString(), cf.ignore(s));
+ }
+
+ @Test
     public void testIgnoreReflectConstructor() {
         CompactFormatter cf = new CompactFormatter();
         String n = java.lang.reflect.Constructor.class.getName();

diff -r bbe7502b3488 -r 5680e2bef1d3 mail/src/test/java/com/sun/mail/util/logging/LogManagerPropertiesTest.java
--- a/mail/src/test/java/com/sun/mail/util/logging/LogManagerPropertiesTest.java Tue Apr 15 15:32:02 2014 -0700
+++ b/mail/src/test/java/com/sun/mail/util/logging/LogManagerPropertiesTest.java Tue Apr 15 15:34:32 2014 -0700
@@ -59,6 +59,7 @@
 
 /**
  * Test case for the LogManagerProperties spec.
+ *
  * @author Jason Mehrens
  */
 public class LogManagerPropertiesTest {
@@ -106,20 +107,28 @@
         assertTrue(LogManagerProperties.isReflectionClass(Method.class.getName()));
     }
 
+ @Test(expected = NullPointerException.class)
+ public void testIsReflectionNull() throws Exception {
+ LogManagerProperties.isReflectionClass((String) null);
+ }
+
+ @Test(expected = ClassNotFoundException.class)
+ public void testIsReflectionInvaildName() throws Exception {
+ LogManagerProperties.isReflectionClass("badClassName");
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testIsStaticUtilityClassNull() throws Exception {
+ LogManagerProperties.isStaticUtilityClass((String) null);
+ }
+
+ @Test(expected = ClassNotFoundException.class)
+ public void testIsStaticUtilityClassInvaildName() throws Exception {
+ LogManagerProperties.isStaticUtilityClass("badClassName");
+ }
+
     @Test
     public void testIsStaticUtilityClass() throws Exception {
- boolean nullCheck;
- try {
- LogManagerProperties.isStaticUtilityClass((String) null);
- nullCheck = false;
- } catch (NullPointerException expect) {
- nullCheck = true;
- }
-
- if (!nullCheck) {
- fail("Null check");
- }
-
         String[] utils = {
             "java.lang.System",
             "java.nio.channels.Channels",
@@ -130,7 +139,6 @@
 
         testIsStaticUtilityClass(utils, true);
 
-
         String[] obj = {
             "java.lang.Exception",
             "java.lang.Object",
@@ -143,23 +151,6 @@
             "java.util.concurrent.TimeUnit"
         };
         testIsStaticUtilityClass(enumerations, false);
-
- String[] fail = {
- "badClassName"
- };
- for (String name : fail) {
- boolean pass;
- try {
- LogManagerProperties.isStaticUtilityClass(name);
- pass = false;
- } catch(ClassNotFoundException expect) {
- pass = true;
- }
-
- if (!pass) {
- fail(name);
- }
- }
     }
 
     private void testIsStaticUtilityClass(String[] names, boolean complement) throws Exception {
@@ -433,11 +424,10 @@
         }
 
         final Class<?> type = ErrorAuthenticator.class;
- final javax.mail.Authenticator a =
- LogManagerProperties.newAuthenticator(type.getName());
+ final javax.mail.Authenticator a
+ = LogManagerProperties.newAuthenticator(type.getName());
         assertEquals(type, a.getClass());
 
-
         setPending(new RuntimeException());
         try {
             LogManagerProperties.newAuthenticator(type.getName());
@@ -470,8 +460,8 @@
         }
 
         final Class<?> type = ErrorComparator.class;
- final Comparator<? super LogRecord> c =
- LogManagerProperties.newComparator(type.getName());
+ final Comparator<? super LogRecord> c
+ = LogManagerProperties.newComparator(type.getName());
         assertEquals(type, c.getClass());
 
         setPending(new RuntimeException());
@@ -509,7 +499,6 @@
         assertTrue(r instanceof DescComparator);
     }
 
-
     @Test
     public void testNewErrorManager() throws Exception {
         try {
@@ -808,7 +797,7 @@
     }
 
     public static class ErrorComparator implements Comparator<LogRecord>,
- Serializable {
+ Serializable {
 
         private static final long serialVersionUID = 1L;
 
@@ -822,7 +811,8 @@
     }
 
     public static class AscComparator implements Comparator<LogRecord>,
- Serializable {
+ Serializable {
+
         private static final long serialVersionUID = 1L;
 
         public int compare(LogRecord r1, LogRecord r2) {
@@ -835,7 +825,8 @@
     }
 
     public static class DescComparator implements Comparator<LogRecord>,
- Serializable {
+ Serializable {
+
         private static final long serialVersionUID = 1L;
 
         public int compare(LogRecord r1, LogRecord r2) {


diff -r 5680e2bef1d3 -r fa1d6f3cde2c doc/release/CHANGES.txt
--- a/doc/release/CHANGES.txt Tue Apr 15 15:34:32 2014 -0700
+++ b/doc/release/CHANGES.txt Tue Apr 15 15:53:07 2014 -0700
@@ -37,6 +37,7 @@
 K 6336 handle multiple IMAP BODY elements in a single FETCH response
 K 6352 add more efficient way to monitor multiple folders for new messages
 K 6353 Include a subject formatter for the logging package
+K 6365 Broken equals in URLName, NewsAddress
 
 
                   CHANGES IN THE 1.5.1 RELEASE

diff -r 5680e2bef1d3 -r fa1d6f3cde2c mail/src/main/java/javax/mail/URLName.java
--- a/mail/src/main/java/javax/mail/URLName.java Tue Apr 15 15:34:32 2014 -0700
+++ b/mail/src/main/java/javax/mail/URLName.java Tue Apr 15 15:53:07 2014 -0700
@@ -1,7 +1,7 @@
 /*
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
  *
- * Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2014 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
@@ -439,7 +439,8 @@
         URLName u2 = (URLName)obj;
 
         // compare protocols
- if (u2.protocol == null || !u2.protocol.equals(protocol))
+ if (!(protocol == u2.protocol ||
+ (protocol != null && protocol.equals(u2.protocol))))
             return false;
 
         // compare hosts

diff -r 5680e2bef1d3 -r fa1d6f3cde2c mail/src/main/java/javax/mail/internet/NewsAddress.java
--- a/mail/src/main/java/javax/mail/internet/NewsAddress.java Tue Apr 15 15:34:32 2014 -0700
+++ b/mail/src/main/java/javax/mail/internet/NewsAddress.java Tue Apr 15 15:53:07 2014 -0700
@@ -1,7 +1,7 @@
 /*
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
  *
- * Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2014 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
@@ -145,7 +145,8 @@
             return false;
 
         NewsAddress s = (NewsAddress)a;
- return newsgroup.equals(s.newsgroup) &&
+ return ((newsgroup == null && s.newsgroup == null) ||
+ (newsgroup != null && newsgroup.equals(s.newsgroup))) &&
             ((host == null && s.host == null) ||
              (host != null && s.host != null && host.equalsIgnoreCase(s.host)));
     }

diff -r 5680e2bef1d3 -r fa1d6f3cde2c mail/src/test/java/javax/mail/URLNameTest.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mail/src/test/java/javax/mail/URLNameTest.java Tue Apr 15 15:53:07 2014 -0700
@@ -0,0 +1,60 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2014 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;
+
+import org.junit.*;
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Test the URLName class.
+ *
+ * XXX - for now, just some simple regression tests for reported bugs.
+ */
+public class URLNameTest {
+
+ @Test
+ public void testReflexiveEquality() throws Exception {
+ URLName u = new URLName("test");
+ assertEquals(u, u); // bug 6365
+ u = new URLName("imap://test.com/INBOX");
+ assertEquals(u, u);
+ }
+}

diff -r 5680e2bef1d3 -r fa1d6f3cde2c mail/src/test/java/javax/mail/internet/NewsAddressTest.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mail/src/test/java/javax/mail/internet/NewsAddressTest.java Tue Apr 15 15:53:07 2014 -0700
@@ -0,0 +1,60 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2014 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.assertEquals;
+
+/**
+ * Test the NewsAddress class.
+ *
+ * XXX - for now, just some simple regression tests for reported bugs.
+ */
+public class NewsAddressTest {
+
+ @Test
+ public void testReflexiveEquality() throws Exception {
+ NewsAddress a = new NewsAddress();
+ assertEquals(a, a); // bug 6365
+ a = new NewsAddress("net.unix");
+ assertEquals(a, a);
+ }
+}


diff -r fa1d6f3cde2c -r 400575ffd5f8 mail/src/main/java/com/sun/mail/util/logging/CollectorFormatter.java
--- a/mail/src/main/java/com/sun/mail/util/logging/CollectorFormatter.java Tue Apr 15 15:53:07 2014 -0700
+++ b/mail/src/main/java/com/sun/mail/util/logging/CollectorFormatter.java Fri Apr 18 16:24:11 2014 -0700
@@ -61,8 +61,9 @@
  * <li>&lt;formatter-name&gt;.comparator name of a
  * {_at_linkplain java.util.Comparator} class used to choose the collected
  * <tt>LogRecord</tt>. If a comparator is specified then the max
- * <tt>LogRecord</tt> is chosen. If a comparator is not specified then, the last
- * record is chosen (defaults to <tt>null</tt>).
+ * <tt>LogRecord</tt> is chosen. If comparator is set to the string literal
+ * null, then the last record is chosen. (defaults to
+ * {_at_link SeverityComparator})
  *
  * <li>&lt;formatter-name&gt;.comparator.reverse a boolean
  * <tt>true</tt> to collect the min <tt>LogRecord</tt> or <tt>false</tt> to
@@ -72,7 +73,7 @@
  * {_at_linkplain java.text.MessageFormat MessageFormat} string used to format the
  * collected summary statistics. The arguments are explained in detail in the
  * {_at_linkplain #getTail(java.util.logging.Handler) getTail} documentation.
- * (defaults to "{0}{1}{2}{4,choice,-1#|0&lt;... {4,number,integer} more}\n")
+ * (defaults to "{0}{1}{2}{4,choice,-1#|0#|0&lt;... {4,number,integer} more}\n")
  *
  * <li>&lt;formatter-name&gt;.formatter name of a <tt>Formatter</tt> class used
  * to format the collected LogRecord. (defaults to {_at_link CompactFormatter})
@@ -127,8 +128,8 @@
      *
      * @throws SecurityException if a security manager exists and the caller
      * does not have <tt>LoggingPermission("control")</tt>.
- * @throws UndeclaredThrowableException if there are problems when loading
- * from the LogManager.
+ * @throws UndeclaredThrowableException if there are problems loading from
+ * the LogManager.
      */
     public CollectorFormatter() {
         final String p = getClass().getName();
@@ -144,8 +145,8 @@
      * @param format the message format or null to use the LogManager default.
      * @throws SecurityException if a security manager exists and the caller
      * does not have <tt>LoggingPermission("control")</tt>.
- * @throws UndeclaredThrowableException if there are problems when loading
- * from the LogManager.
+ * @throws UndeclaredThrowableException if there are problems loading from
+ * the LogManager.
      */
     public CollectorFormatter(String format) {
         final String p = getClass().getName();
@@ -158,15 +159,15 @@
     /**
      * Creates the formatter using the given values.
      *
- * @param format the format string.
- * @param f the formatter used on the collected log record or null to use
- * the LogManager default.
+ * @param format the format string or null to use the LogManager default.
+ * @param f the formatter used on the collected log record or null to
+ * specify no formatter.
      * @param c the comparator used to determine which log record to format or
      * null to specify no comparator.
      * @throws SecurityException if a security manager exists and the caller
      * does not have <tt>LoggingPermission("control")</tt>.
- * @throws UndeclaredThrowableException if there are problems when loading
- * from the LogManager.
+ * @throws UndeclaredThrowableException if there are problems loading from
+ * the LogManager.
      */
     public CollectorFormatter(String format, Formatter f,
             Comparator<? super LogRecord> c) {
@@ -179,7 +180,7 @@
 
     /**
      * Accumulates log records which will be used to produce the final output.
- * The output is generated using the {_at_link getTail} method which also
+ * The output is generated using the {_at_link #getTail} method which also
      * resets this formatter back to its original state.
      *
      * @param record the record to store.
@@ -210,7 +211,9 @@
 
     /**
      * Formats the collected LogRecord and summary statistics. The collected
- * results are reset after calling this method.
+ * results are reset after calling this method. The
+ * {_at_link java.text.MessageFormat java.text} argument indexes are assigned
+ * to the following properties:
      *
      * <ol start='0'>
      * <li>{_at_code head} the
@@ -371,9 +374,8 @@
             l = rb == null ? null : rb.getLocale();
         }
 
- //NumberFormat used by the MessageFormat requires a non null locale.
         final MessageFormat mf;
- if (l == null) {
+ if (l == null) { //BUG ID 8039165
             mf = new MessageFormat(fmt);
         } else {
             mf = new MessageFormat(fmt, l);
@@ -436,7 +438,7 @@
         final LogManager m = LogManagerProperties.getLogManager();
         String v = m.getProperty(p.concat(".format"));
         if (v == null || v.length() == 0) {
- v = "{0}{1}{2}{4,choice,-1#|0<... {4,number,integer} more}\n";
+ v = "{0}{1}{2}{4,choice,-1#|0#|0<... {4,number,integer} more}\n";
         }
         return v;
     }
@@ -490,7 +492,7 @@
         final String name = m.getProperty(p.concat(".comparator"));
         final String reverse = m.getProperty(p.concat(".comparator.reverse"));
         try {
- if (name != null) {
+ if (name != null && name.length() != 0) {
                 if (!"null".equalsIgnoreCase(name)) {
                     c = LogManagerProperties.newComparator(name);
                     if (Boolean.parseBoolean(reverse)) {

diff -r fa1d6f3cde2c -r 400575ffd5f8 mail/src/main/java/com/sun/mail/util/logging/CompactFormatter.java
--- a/mail/src/main/java/com/sun/mail/util/logging/CompactFormatter.java Tue Apr 15 15:53:07 2014 -0700
+++ b/mail/src/main/java/com/sun/mail/util/logging/CompactFormatter.java Fri Apr 18 16:24:11 2014 -0700
@@ -81,9 +81,9 @@
     /**
      * Creates an instance with the given format pattern.
      *
- * @param format the {_at_link java.util.Formatter pattern}. The arguments are
- * described in the {_at_link #format(java.util.logging.LogRecord) format}
- * method.
+ * @param format the {_at_link java.util.Formatter pattern} or null to use the
+ * LogManager default. The arguments are described in the
+ * {_at_link #format(java.util.logging.LogRecord) format} method.
      */
     public CompactFormatter(final String format) {
         String p = getClass().getName();
@@ -91,7 +91,9 @@
     }
 
     /**
- * Format the given log record and returns the formatted string.
+ * Format the given log record and returns the formatted string. The
+ * {_at_link java.util.Formatter#format(java.lang.String, java.lang.Object...)
+ * java.util} argument indexes are assigned to the following properties:
      *
      * <ol start='0'>
      * <li>{_at_code format} - the {_at_link java.util.Formatter


diff -r 400575ffd5f8 -r 8ceae3160136 doc/release/CHANGES.txt
--- a/doc/release/CHANGES.txt Fri Apr 18 16:24:11 2014 -0700
+++ b/doc/release/CHANGES.txt Fri Apr 18 16:39:57 2014 -0700
@@ -38,6 +38,7 @@
 K 6352 add more efficient way to monitor multiple folders for new messages
 K 6353 Include a subject formatter for the logging package
 K 6365 Broken equals in URLName, NewsAddress
+K 6366 NullPointerException in ContentType.match
 
 
                   CHANGES IN THE 1.5.1 RELEASE

diff -r 400575ffd5f8 -r 8ceae3160136 mail/src/main/java/javax/mail/internet/ContentType.java
--- a/mail/src/main/java/javax/mail/internet/ContentType.java Fri Apr 18 16:24:11 2014 -0700
+++ b/mail/src/main/java/javax/mail/internet/ContentType.java Fri Apr 18 16:39:57 2014 -0700
@@ -141,6 +141,8 @@
      * @return the type
      */
     public String getBaseType() {
+ if (primaryType == null || subType == null)
+ return "";
         return primaryType + '/' + subType;
     }
 
@@ -249,20 +251,21 @@
      */
     public boolean match(ContentType cType) {
         // Match primaryType
- if (!primaryType.equalsIgnoreCase(cType.getPrimaryType()))
+ if (!((primaryType == null && cType.getPrimaryType() == null) ||
+ (primaryType != null &&
+ primaryType.equalsIgnoreCase(cType.getPrimaryType()))))
             return false;
         
         String sType = cType.getSubType();
 
         // If either one of the subTypes is wildcarded, return true
- if ((subType.charAt(0) == '*') || (sType.charAt(0) == '*'))
+ if ((subType != null && subType.startsWith("*")) ||
+ (sType != null && sType.startsWith("*")))
             return true;
         
         // Match subType
- if (!subType.equalsIgnoreCase(sType))
- return false;
-
- return true;
+ return (subType == null && sType == null) ||
+ (subType != null && subType.equalsIgnoreCase(sType));
     }
 
     /**

diff -r 400575ffd5f8 -r 8ceae3160136 mail/src/test/java/javax/mail/internet/ContentTypeTest.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mail/src/test/java/javax/mail/internet/ContentTypeTest.java Fri Apr 18 16:39:57 2014 -0700
@@ -0,0 +1,67 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2014 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.assertFalse;
+
+/**
+ * Test the ContentType class.
+ *
+ * XXX - for now, just some simple regression tests for reported bugs.
+ */
+public class ContentTypeTest {
+
+ @Test
+ public void testMatch() throws Exception {
+ ContentType empty = new ContentType();
+ assertFalse(empty.match("text/plain"));
+ ContentType plain = new ContentType("text/plain");
+ assertTrue(plain.match("text/plain"));
+ assertFalse(empty.match(plain));
+ assertFalse(plain.match(empty));
+ assertTrue(plain.match("text/*"));
+ ContentType text = new ContentType("text/*");
+ assertTrue(text.match(plain));
+ assertTrue(plain.match(text));
+ }
+}


diff -r 8ceae3160136 -r 960ea2ae6d92 doc/release/CHANGES.txt
--- a/doc/release/CHANGES.txt Fri Apr 18 16:39:57 2014 -0700
+++ b/doc/release/CHANGES.txt Fri Apr 18 16:50:16 2014 -0700
@@ -39,6 +39,8 @@
 K 6353 Include a subject formatter for the logging package
 K 6365 Broken equals in URLName, NewsAddress
 K 6366 NullPointerException in ContentType.match
+K 6367 hashCode of two equals instances does not match for ModifiedSinceTerm,
+ YoungerTerm, OlderTerm
 
 
                   CHANGES IN THE 1.5.1 RELEASE

diff -r 8ceae3160136 -r 960ea2ae6d92 mail/src/main/java/com/sun/mail/imap/ModifiedSinceTerm.java
--- a/mail/src/main/java/com/sun/mail/imap/ModifiedSinceTerm.java Fri Apr 18 16:39:57 2014 -0700
+++ b/mail/src/main/java/com/sun/mail/imap/ModifiedSinceTerm.java Fri Apr 18 16:50:16 2014 -0700
@@ -1,7 +1,7 @@
 /*
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
  *
- * Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2014 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
@@ -110,6 +110,6 @@
      * Compute a hashCode for this object.
      */
     public int hashCode() {
- return (int)modseq + super.hashCode();
+ return (int)modseq;
     }
 }

diff -r 8ceae3160136 -r 960ea2ae6d92 mail/src/main/java/com/sun/mail/imap/OlderTerm.java
--- a/mail/src/main/java/com/sun/mail/imap/OlderTerm.java Fri Apr 18 16:39:57 2014 -0700
+++ b/mail/src/main/java/com/sun/mail/imap/OlderTerm.java Fri Apr 18 16:50:16 2014 -0700
@@ -1,7 +1,7 @@
 /*
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
  *
- * Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2014 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
@@ -112,6 +112,6 @@
      * Compute a hashCode for this object.
      */
     public int hashCode() {
- return interval + super.hashCode();
+ return interval;
     }
 }

diff -r 8ceae3160136 -r 960ea2ae6d92 mail/src/main/java/com/sun/mail/imap/YoungerTerm.java
--- a/mail/src/main/java/com/sun/mail/imap/YoungerTerm.java Fri Apr 18 16:39:57 2014 -0700
+++ b/mail/src/main/java/com/sun/mail/imap/YoungerTerm.java Fri Apr 18 16:50:16 2014 -0700
@@ -1,7 +1,7 @@
 /*
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
  *
- * Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2014 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
@@ -112,6 +112,6 @@
      * Compute a hashCode for this object.
      */
     public int hashCode() {
- return interval + super.hashCode();
+ return interval;
     }
 }


diff -r 960ea2ae6d92 -r 0af49993bf64 doc/release/CHANGES.txt
--- a/doc/release/CHANGES.txt Fri Apr 18 16:50:16 2014 -0700
+++ b/doc/release/CHANGES.txt Fri Apr 18 17:14:19 2014 -0700
@@ -41,6 +41,7 @@
 K 6366 NullPointerException in ContentType.match
 K 6367 hashCode of two equals instances does not match for ModifiedSinceTerm,
         YoungerTerm, OlderTerm
+K 6368 NullPointerException in InternetAddress
 
 
                   CHANGES IN THE 1.5.1 RELEASE

diff -r 960ea2ae6d92 -r 0af49993bf64 mail/src/main/java/javax/mail/internet/InternetAddress.java
--- a/mail/src/main/java/javax/mail/internet/InternetAddress.java Fri Apr 18 16:50:16 2014 -0700
+++ b/mail/src/main/java/javax/mail/internet/InternetAddress.java Fri Apr 18 17:14:19 2014 -0700
@@ -1,7 +1,7 @@
 /*
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
  *
- * Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2014 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
@@ -288,17 +288,18 @@
      * @return possibly encoded address string
      */
     public String toString() {
+ String a = address == null ? "" : address;
         if (encodedPersonal == null && personal != null)
             try {
                 encodedPersonal = MimeUtility.encodeWord(personal);
             } catch (UnsupportedEncodingException ex) { }
         
         if (encodedPersonal != null)
- return quotePhrase(encodedPersonal) + " <" + address + ">";
+ return quotePhrase(encodedPersonal) + " <" + a + ">";
         else if (isGroup() || isSimple())
- return address;
+ return a;
         else
- return "<" + address + ">";
+ return "<" + a + ">";
     }
 
     /**
@@ -1148,6 +1149,8 @@
                                 throws AddressException {
         int i, start = 0;
 
+ if (addr == null)
+ throw new AddressException("Address is null");
         int len = addr.length();
         if (len == 0)
             throw new AddressException("Empty address", addr);
@@ -1318,6 +1321,8 @@
      */
     public InternetAddress[] getGroup(boolean strict) throws AddressException {
         String addr = getAddress();
+ if (addr == null)
+ return null;
         // groups are of the form "name:addr,addr,...;"
         if (!addr.endsWith(";"))
             return null;