james-mime4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ieu...@apache.org
Subject svn commit: r1390619 - in /james/mime4j/trunk/dom/src: main/java/org/apache/james/mime4j/dom/address/ main/java/org/apache/james/mime4j/field/address/ test/java/org/apache/james/mime4j/field/address/
Date Wed, 26 Sep 2012 17:21:26 GMT
Author: ieugen
Date: Wed Sep 26 17:21:25 2012
New Revision: 1390619

URL: http://svn.apache.org/viewvc?rev=1390619&view=rev
Log:
Made DomainList immutable, fixes MIME4J-217

Modified:
    james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/dom/address/DomainList.java
    james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/dom/address/Mailbox.java
    james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/field/address/Builder.java
    james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/field/address/LenientAddressBuilder.java
    james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/field/address/AddressTest.java
    james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/field/address/DefaultAddressFormatterTest.java

Modified: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/dom/address/DomainList.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/dom/address/DomainList.java?rev=1390619&r1=1390618&r2=1390619&view=diff
==============================================================================
--- james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/dom/address/DomainList.java
(original)
+++ james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/dom/address/DomainList.java
Wed Sep 26 17:21:25 2012
@@ -29,24 +29,17 @@ import java.util.List;
  * An immutable, random-access list of Strings (that are supposedly domain names
  * or domain literals).
  */
-public class DomainList extends AbstractList<String> implements Serializable {
+public final class DomainList extends AbstractList<String> implements Serializable
{
 
     private static final long serialVersionUID = 1L;
 
     private final List<String> domains;
 
     /**
-     * @param domains
-     *            A List that contains only String objects.
-     * @param dontCopy
-     *            true iff it is not possible for the domains list to be
-     *            modified by someone else.
+     * @param domains  A List that contains only String objects.
      */
-    public DomainList(List<String> domains, boolean dontCopy) {
-        if (domains != null)
-            this.domains = dontCopy ? domains : new ArrayList<String>(domains);
-        else
-            this.domains = Collections.emptyList();
+    public DomainList(List<String> domains) {
+        this.domains = (domains == null) ? Collections.<String>emptyList():new ArrayList<String>(domains);
     }
 
     /**

Modified: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/dom/address/Mailbox.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/dom/address/Mailbox.java?rev=1390619&r1=1390618&r2=1390619&view=diff
==============================================================================
--- james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/dom/address/Mailbox.java
(original)
+++ james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/dom/address/Mailbox.java
Wed Sep 26 17:21:25 2012
@@ -33,7 +33,7 @@ public class Mailbox extends Address {
     private static final long serialVersionUID = 1L;
 
     private static final DomainList EMPTY_ROUTE_LIST = new DomainList(
-            Collections.<String> emptyList(), true);
+            Collections.<String> emptyList());
 
     private final String name;
     private final DomainList route;

Modified: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/field/address/Builder.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/field/address/Builder.java?rev=1390619&r1=1390618&r2=1390619&view=diff
==============================================================================
--- james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/field/address/Builder.java
(original)
+++ james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/field/address/Builder.java
Wed Sep 26 17:21:25 2012
@@ -164,7 +164,7 @@ class Builder {
             else
                 throw new ParseException();
         }
-        return new DomainList(results, true);
+        return new DomainList(results);
     }
 
     private Mailbox buildAddrSpec(ASTaddr_spec node) {

Modified: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/field/address/LenientAddressBuilder.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/field/address/LenientAddressBuilder.java?rev=1390619&r1=1390618&r2=1390619&view=diff
==============================================================================
--- james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/field/address/LenientAddressBuilder.java
(original)
+++ james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/field/address/LenientAddressBuilder.java
Wed Sep 26 17:21:25 2012
@@ -124,7 +124,7 @@ public class LenientAddressBuilder {
                 break;
             }
         }
-        return domains != null ? new DomainList(domains, true) : null;
+        return domains != null ? new DomainList(domains) : null;
     }
 
     private Mailbox createMailbox(

Modified: james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/field/address/AddressTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/field/address/AddressTest.java?rev=1390619&r1=1390618&r2=1390619&view=diff
==============================================================================
--- james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/field/address/AddressTest.java
(original)
+++ james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/field/address/AddressTest.java
Wed Sep 26 17:21:25 2012
@@ -57,7 +57,7 @@ public class AddressTest extends TestCas
 
 
     public void testEmptyDomainList() {
-        DomainList dl = new DomainList(null, false);
+        DomainList dl = new DomainList(null);
         assertEquals(0, dl.size());
 
         try {
@@ -77,14 +77,14 @@ public class AddressTest extends TestCas
         List<String> al = new ArrayList<String>();
         al.add("example.com");
 
-        // shared arraylist
-        DomainList dl = new DomainList(al, true);
+        // changing the list passed does not change DomainList's state
+        DomainList dl = new DomainList(al);
         assertEquals(1, dl.size());
         al.add("foo.example.com");
-        assertEquals(2, dl.size());
+        assertEquals(1, dl.size());
 
         // cloned arraylist
-        DomainList dlcopy = new DomainList(al, false);
+        DomainList dlcopy = new DomainList(al);
         assertEquals(2, dlcopy.size());
         al.add("bar.example.com");
         assertEquals(2, dlcopy.size());

Modified: james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/field/address/DefaultAddressFormatterTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/field/address/DefaultAddressFormatterTest.java?rev=1390619&r1=1390618&r2=1390619&view=diff
==============================================================================
--- james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/field/address/DefaultAddressFormatterTest.java
(original)
+++ james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/field/address/DefaultAddressFormatterTest.java
Wed Sep 26 17:21:25 2012
@@ -44,7 +44,7 @@ public class DefaultAddressFormatterTest
         al.add(new Mailbox("test", "example.com"));
         al.add(new Mailbox("Foo!", "foo", "example.com"));
         DomainList dl = new DomainList(new ArrayList<String>(
-                Arrays.asList(new String[] {"foo.example.com"})), true);
+                Arrays.asList(new String[] {"foo.example.com"})));
         Mailbox mailbox = new Mailbox("Foo Bar", dl, "foo2", "example.com");
         assertSame(dl, mailbox.getRoute());
         al.add(mailbox);



Mime
View raw message