commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r896818 - in /commons/proper/compress/trunk/src: changes/changes.xml main/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntry.java test/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntryTest.java
Date Thu, 07 Jan 2010 09:36:04 GMT
Author: bodewig
Date: Thu Jan  7 09:34:55 2010
New Revision: 896818

URL: http://svn.apache.org/viewvc?rev=896818&view=rev
Log:
ZipArchiveEntry#equals is broken if the String-arg constructor is used.  COMPRESS-94 - submitted
by Anon Devs

Modified:
    commons/proper/compress/trunk/src/changes/changes.xml
    commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntry.java
    commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntryTest.java

Modified: commons/proper/compress/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/changes/changes.xml?rev=896818&r1=896817&r2=896818&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/changes/changes.xml (original)
+++ commons/proper/compress/trunk/src/changes/changes.xml Thu Jan  7 09:34:55 2010
@@ -23,6 +23,12 @@
   </properties>
   <body>
     <release version="1.1" date="as in SVN" description="Release 1.1">
+      <action type="fix" issue="COMPRESS-94" date="2010-01-07"
+              due-to="Anon Devs">
+        ZipArchiveEntry's equals method was broken for entries created
+        with the String-arg constructor.  This lead to broken ZIP
+        archives if two different entries had the same hash code.
+      </action>
       <action type="fix" issue="COMPRESS-87" date="2009-10-30"
               due-to="Antoni Mylka">
         ZipArchiveInputStream could repeatedly return 0 on read() when

Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntry.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntry.java?rev=896818&r1=896817&r2=896818&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntry.java
(original)
+++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntry.java
Thu Jan  7 09:34:55 2010
@@ -61,6 +61,7 @@
      */
     public ZipArchiveEntry(String name) {
         super(name);
+        setName(name);
     }
 
     /**
@@ -96,7 +97,7 @@
     /**
      */
     protected ZipArchiveEntry() {
-        super("");
+        this("");
     }
 
     public ZipArchiveEntry(File inputFile, String entryName) {
@@ -459,11 +460,13 @@
             return false;
         }
         ZipArchiveEntry other = (ZipArchiveEntry) obj;
-        if (name == null) {
-            if (other.name != null) {
+        String myName = getName();
+        String otherName = other.getName();
+        if (myName == null) {
+            if (otherName != null) {
                 return false;
             }
-        } else if (!name.equals(other.name)) {
+        } else if (!myName.equals(otherName)) {
             return false;
         }
         return true;

Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntryTest.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntryTest.java?rev=896818&r1=896817&r2=896818&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntryTest.java
(original)
+++ commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntryTest.java
Thu Jan  7 09:34:55 2010
@@ -219,4 +219,14 @@
         assertFalse(entry.isSupportedCompressionMethod());
     }
 
+    /**
+     * Test case for
+     * <a href="https://issues.apache.org/jira/browse/COMPRESS-94"
+     * >COMPRESS-94</a>.
+     */
+    public void testNotEquals() {
+        ZipArchiveEntry entry1 = new ZipArchiveEntry("foo");
+        ZipArchiveEntry entry2 = new ZipArchiveEntry("bar");
+        assertFalse(entry1.equals(entry2));
+    }
 }



Mime
View raw message