felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rickh...@apache.org
Subject svn commit: r916123 - /felix/sandbox/rickhall/framework-proto/src/main/java/org/apache/felix/framework/capabilityset/CapabilitySet.java
Date Thu, 25 Feb 2010 04:52:33 GMT
Author: rickhall
Date: Thu Feb 25 04:52:33 2010
New Revision: 916123

URL: http://svn.apache.org/viewvc?rev=916123&view=rev
Log:
Throw exception when type coercion fails and report match failure.

Modified:
    felix/sandbox/rickhall/framework-proto/src/main/java/org/apache/felix/framework/capabilityset/CapabilitySet.java

Modified: felix/sandbox/rickhall/framework-proto/src/main/java/org/apache/felix/framework/capabilityset/CapabilitySet.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/framework-proto/src/main/java/org/apache/felix/framework/capabilityset/CapabilitySet.java?rev=916123&r1=916122&r2=916123&view=diff
==============================================================================
--- felix/sandbox/rickhall/framework-proto/src/main/java/org/apache/felix/framework/capabilityset/CapabilitySet.java
(original)
+++ felix/sandbox/rickhall/framework-proto/src/main/java/org/apache/felix/framework/capabilityset/CapabilitySet.java
Thu Feb 25 04:52:33 2010
@@ -351,7 +351,14 @@
             }
             else
             {
-                rhs = coerceType(lhs, (String) rhsUnknown);
+                try
+                {
+                    rhs = coerceType(lhs, (String) rhsUnknown);
+                }
+                catch (Exception ex)
+                {
+                    return false;
+                }
             }
 
             switch (op)
@@ -374,7 +381,16 @@
         // Booleans do not implement comparable, so special case them.
         else if (lhs instanceof Boolean)
         {
-            Object rhs = coerceType(lhs, (String) rhsUnknown);
+            Object rhs;
+            try
+            {
+                rhs = coerceType(lhs, (String) rhsUnknown);
+            }
+            catch (Exception ex)
+            {
+                return false;
+            }
+
             switch (op)
             {
                 case SimpleFilter.EQ :
@@ -413,10 +429,17 @@
 
         // Since we cannot identify the LHS type, then we can only perform
         // equality comparison.
-        return lhs.equals(coerceType(lhs, (String) rhsUnknown));
+        try
+        {
+            return lhs.equals(coerceType(lhs, (String) rhsUnknown));
+        }
+        catch (Exception ex)
+        {
+            return false;
+        }
     }
 
-    private static Object coerceType(Object lhs, String rhsString)
+    private static Object coerceType(Object lhs, String rhsString) throws Exception
     {
         // If the LHS expects a string, then we can just return
         // the RHS since it is a string.
@@ -445,10 +468,10 @@
         }
         catch (Exception ex)
         {
-            throw new RuntimeException(
+            throw new Exception(
                 "Could not instantiate class "
                     + lhs.getClass().getName()
-                    + " using string constructor with argument '"
+                    + " from string constructor with argument '"
                     + rhsString + "' because " + ex);
         }
 



Mime
View raw message