Modified service reference comparison to check whether rank is an Integer and
if not set the rank to zero. (FELIX-948)


git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@745581 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/framework/src/main/java/org/apache/felix/framework/ServiceRegistrationImpl.java b/framework/src/main/java/org/apache/felix/framework/ServiceRegistrationImpl.java
index d1f26b9..1d46ba2 100644
--- a/framework/src/main/java/org/apache/felix/framework/ServiceRegistrationImpl.java
+++ b/framework/src/main/java/org/apache/felix/framework/ServiceRegistrationImpl.java
@@ -461,12 +461,18 @@
                 return 0; // same service
             }
 
-            Integer rank = (Integer) getProperty(Constants.SERVICE_RANKING);
-            Integer otherRank = (Integer) other.getProperty(Constants.SERVICE_RANKING);
+            Object rankObj = (Integer) getProperty(Constants.SERVICE_RANKING);
+            Object otherRankObj = (Integer) other.getProperty(Constants.SERVICE_RANKING);
 
             // If no rank, then spec says it defaults to zero.
-            rank = (rank == null) ? new Integer(0) : rank;
-            otherRank = (otherRank == null) ? new Integer(0) : otherRank;
+            rankObj = (rankObj == null) ? new Integer(0) : rankObj;
+            otherRankObj = (otherRankObj == null) ? new Integer(0) : otherRankObj;
+
+            // If rank is not Integer, then spec says it defaults to zero.
+            Integer rank = (rankObj instanceof Integer)
+                ? new Integer(0) : (Integer) rankObj;
+            Integer otherRank = (otherRankObj instanceof Integer)
+                ? new Integer(0) : (Integer) otherRankObj;
 
             // Sort by rank in ascending order.
             if (rank.compareTo(otherRank) < 0)