felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rickh...@apache.org
Subject svn commit: r1199603 - in /felix/trunk/framework/src: main/java/org/apache/felix/framework/capabilityset/ test/java/org/apache/felix/framework/capabilityset/
Date Wed, 09 Nov 2011 03:30:46 GMT
Author: rickhall
Date: Wed Nov  9 03:30:45 2011
New Revision: 1199603

URL: http://svn.apache.org/viewvc?rev=1199603&view=rev
Log:
Fix a couple of bugs in substring matching and null handling when
matching collections. (FELIX-3207)

Modified:
    felix/trunk/framework/src/main/java/org/apache/felix/framework/capabilityset/CapabilitySet.java
    felix/trunk/framework/src/main/java/org/apache/felix/framework/capabilityset/SimpleFilter.java
    felix/trunk/framework/src/test/java/org/apache/felix/framework/capabilityset/SimpleFilterTest.java

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/capabilityset/CapabilitySet.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/capabilityset/CapabilitySet.java?rev=1199603&r1=1199602&r2=1199603&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/capabilityset/CapabilitySet.java
(original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/capabilityset/CapabilitySet.java
Wed Nov  9 03:30:45 2011
@@ -366,10 +366,15 @@ public void dump()
         return false;
     }
 
-    private static final Class[] STRING_CLASS = new Class[] { String.class };
+    private static final Class<?>[] STRING_CLASS = new Class[] { String.class };
 
     private static boolean compare(Object lhs, Object rhsUnknown, int op)
     {
+        if (lhs == null)
+        {
+            return false;
+        }
+        
         // If this is a PRESENT operation, then just return true immediately
         // since we wouldn't be here if the attribute wasn't present.
         if (op == SimpleFilter.PRESENT)

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/capabilityset/SimpleFilter.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/capabilityset/SimpleFilter.java?rev=1199603&r1=1199602&r2=1199603&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/capabilityset/SimpleFilter.java
(original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/capabilityset/SimpleFilter.java
Wed Nov  9 03:30:45 2011
@@ -502,9 +502,9 @@ loop:   for (int i = 0; i < len; i++)
 
             // If this is the last piece, then make sure the
             // string ends with it.
-            if (i == len - 1)
+            if (i == (len - 1))
             {
-                if (s.endsWith(piece))
+                if (s.endsWith(piece) && (s.length() >= (index + piece.length())))
                 {
                     result = true;
                 }

Modified: felix/trunk/framework/src/test/java/org/apache/felix/framework/capabilityset/SimpleFilterTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/test/java/org/apache/felix/framework/capabilityset/SimpleFilterTest.java?rev=1199603&r1=1199602&r2=1199603&view=diff
==============================================================================
--- felix/trunk/framework/src/test/java/org/apache/felix/framework/capabilityset/SimpleFilterTest.java
(original)
+++ felix/trunk/framework/src/test/java/org/apache/felix/framework/capabilityset/SimpleFilterTest.java
Wed Nov  9 03:30:45 2011
@@ -73,5 +73,11 @@ public class SimpleFilterTest extends Te
 
         pieces = SimpleFilter.parseSubstring("*foo(*bar*");
         assertTrue("Should match!", SimpleFilter.compareSubstring(pieces, "foo()bar"));
+
+        pieces = SimpleFilter.parseSubstring("*foo*bar*bar");
+        assertFalse("Should not match!", SimpleFilter.compareSubstring(pieces, "foobar"));
+
+        pieces = SimpleFilter.parseSubstring("aaaa*aaaa");
+        assertFalse("Should not match!", SimpleFilter.compareSubstring(pieces, "aaaaaaa"));
     }
 }



Mime
View raw message