sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1159652 - in /sling/trunk/installer/core/src: main/java/org/apache/sling/installer/core/impl/RegisteredResourceImpl.java test/java/org/apache/sling/installer/core/impl/RegisteredResourceComparatorTest.java
Date Fri, 19 Aug 2011 14:45:52 GMT
Author: cziegeler
Date: Fri Aug 19 14:45:51 2011
New Revision: 1159652

URL: http://svn.apache.org/viewvc?rev=1159652&view=rev
Log:
SLING-2190 : Digest should be compared in reverse order

Modified:
    sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/RegisteredResourceImpl.java
    sling/trunk/installer/core/src/test/java/org/apache/sling/installer/core/impl/RegisteredResourceComparatorTest.java

Modified: sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/RegisteredResourceImpl.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/RegisteredResourceImpl.java?rev=1159652&r1=1159651&r2=1159652&view=diff
==============================================================================
--- sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/RegisteredResourceImpl.java
(original)
+++ sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/RegisteredResourceImpl.java
Fri Aug 19 14:45:51 2011
@@ -403,7 +403,8 @@ public class RegisteredResourceImpl
 
                 // check digest
                 if ( result == 0 ) {
-                    result = a.getDigest().compareTo(b.getDigest());
+                    // higher digest has more priority, must come first so invert comparison
+                    result = b.getDigest().compareTo(a.getDigest());
                 }
             }
         }
@@ -442,7 +443,8 @@ public class RegisteredResourceImpl
         }
 
         if (result == 0 && isSnapshot) {
-            result = a.getDigest().compareTo(b.getDigest());
+            // higher digest has more priority, must come first so invert comparison
+            result = b.getDigest().compareTo(a.getDigest());
         }
 
         return result;

Modified: sling/trunk/installer/core/src/test/java/org/apache/sling/installer/core/impl/RegisteredResourceComparatorTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/core/src/test/java/org/apache/sling/installer/core/impl/RegisteredResourceComparatorTest.java?rev=1159652&r1=1159651&r2=1159652&view=diff
==============================================================================
--- sling/trunk/installer/core/src/test/java/org/apache/sling/installer/core/impl/RegisteredResourceComparatorTest.java
(original)
+++ sling/trunk/installer/core/src/test/java/org/apache/sling/installer/core/impl/RegisteredResourceComparatorTest.java
Fri Aug 19 14:45:51 2011
@@ -136,15 +136,18 @@ public class RegisteredResourceComparato
         final MockBundleResource a = new MockBundleResource("a", "1.2.0", 0, "digestA");
         final MockBundleResource b = new MockBundleResource("a", "1.2.0", 0, "digestB");
         assertEquals("Digests must not be included in bundles comparison", 0, a.compareTo(b));
+        final MockBundleResource c = new MockBundleResource("a", "1.2.0.SNAPSHOT", 0, "1000");
+        final MockBundleResource d = new MockBundleResource("a", "1.2.0.SNAPSHOT", 0, "2000");
+        assertEquals("Digests should be compared with highest first", 1, c.compareTo(d));
     }
 
     @Test
     public void testSnapshotSerialNumber() {
         // Verify that snapshots with a higher serial number come first
         final RegisteredResource [] inOrder = new RegisteredResource [3];
-        inOrder[2] = new MockBundleResource("a", "1.2.0.SNAPSHOT", 0, "digestC");
+        inOrder[0] = new MockBundleResource("a", "1.2.0.SNAPSHOT", 0, "digestC");
         inOrder[1] = new MockBundleResource("a", "1.2.0.SNAPSHOT", 0, "digestB");
-        inOrder[0] = new MockBundleResource("a", "1.2.0.SNAPSHOT", 0, "digestA");
+        inOrder[2] = new MockBundleResource("a", "1.2.0.SNAPSHOT", 0, "digestA");
         assertOrder(inOrder);
     }
 



Mime
View raw message