felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1579223 - in /felix/sandbox/pderop/dependencymanager-prototype/dm: src/dm/ src/dm/impl/ src/dm/impl/index/ test/test/
Date Wed, 19 Mar 2014 13:21:52 GMT
Author: marrs
Date: Wed Mar 19 13:21:51 2014
New Revision: 1579223

URL: http://svn.apache.org/r1579223
Log:
Changes after a code review. I also reviewed all (default) Findbugs warnings.

Modified:
    felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/FilterIndex.java
    felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/impl/ComponentAdminImpl.java
    felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/impl/EventImpl.java
    felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/impl/ResourceEventImpl.java
    felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/impl/index/AspectFilterIndex.java
    felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/impl/index/BundleContextInterceptor.java
    felix/sandbox/pderop/dependencymanager-prototype/dm/test/test/SerialExecutorTest.java
    felix/sandbox/pderop/dependencymanager-prototype/dm/test/test/ServiceRaceTest.java

Modified: felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/FilterIndex.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/FilterIndex.java?rev=1579223&r1=1579222&r2=1579223&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/FilterIndex.java (original)
+++ felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/FilterIndex.java Wed Mar 19
13:21:51 2014
@@ -36,7 +36,7 @@ public interface FilterIndex {
     public void close();
     /** Determines if the combination of class and filter is applicable for this filter index.
*/
     public boolean isApplicable(String clazz, String filter);
-    /** Returns all service references that match the specified class and filter. */
+    /** Returns all service references that match the specified class and filter. Never returns
null. */
     public List /* <ServiceReference> */ getAllServiceReferences(String clazz, String
filter);
     /** Invoked whenever a service event occurs. */
     public void serviceChanged(ServiceEvent event);

Modified: felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/impl/ComponentAdminImpl.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/impl/ComponentAdminImpl.java?rev=1579223&r1=1579222&r2=1579223&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/impl/ComponentAdminImpl.java
(original)
+++ felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/impl/ComponentAdminImpl.java
Wed Mar 19 13:21:51 2014
@@ -40,7 +40,7 @@ public class ComponentAdminImpl implemen
 
 	@Override
 	public List<ComponentDeclaration> getComponents(Bundle bundle) {
-    	return getComponents(bundle);
+    	return getComponents(bundle, -1);
 	}
 	
 	private List<ComponentDeclaration> getComponents(Bundle bundle, long componentId)
{

Modified: felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/impl/EventImpl.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/impl/EventImpl.java?rev=1579223&r1=1579222&r2=1579223&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/impl/EventImpl.java (original)
+++ felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/impl/EventImpl.java Wed Mar
19 13:21:51 2014
@@ -23,7 +23,9 @@ public class EventImpl implements Event,
 
 	@Override
 	public boolean equals(Object obj) {
-		if (obj instanceof EventImpl) {
+		// an instanceof check here is not "strong" enough with subclasses overriding the
+		// equals: we need to be sure that a.equals(b) == b.equals(a) at all times
+		if (obj != null && obj.getClass().equals(EventImpl.class)) {
 			return ((EventImpl) obj).m_id == m_id;
 		}
 		return false;

Modified: felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/impl/ResourceEventImpl.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/impl/ResourceEventImpl.java?rev=1579223&r1=1579222&r2=1579223&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/impl/ResourceEventImpl.java
(original)
+++ felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/impl/ResourceEventImpl.java
Wed Mar 19 13:21:51 2014
@@ -29,19 +29,13 @@ public class ResourceEventImpl extends E
             if (match) {
                 Dictionary<?,?> d1 = getResourceProperties();
                 Dictionary<?,?> d2 = r2.getResourceProperties();
-
-                if (d1 == null && d2 == null) {
-                    return match;
-                }
                 
-                if (d1 == null && d2 != null) {
-                    return false;
+                if (d1 == null) {
+                	return d2 == null ? match : false;
                 }
-                
-                if (d1 != null && d2 == null) {
-                    return false;
+                else {
+                	return d1.equals(d2);
                 }
-                return d1.equals(d2);
             }
         }
         return false;

Modified: felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/impl/index/AspectFilterIndex.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/impl/index/AspectFilterIndex.java?rev=1579223&r1=1579222&r2=1579223&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/impl/index/AspectFilterIndex.java
(original)
+++ felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/impl/index/AspectFilterIndex.java
Wed Mar 19 13:21:51 2014
@@ -224,7 +224,7 @@ public class AspectFilterIndex extends A
                 				listeners.remove(listener);
                 			}
                 			// cleanup 
-                			if (listeners.isEmpty()) {
+                			if (listeners != null && listeners.isEmpty()) {
                 				rankingToListenersMap.remove(Integer.valueOf(data.ranking));
                 			}
                 			if (rankingToListenersMap.isEmpty()) {

Modified: felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/impl/index/BundleContextInterceptor.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/impl/index/BundleContextInterceptor.java?rev=1579223&r1=1579222&r2=1579223&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/impl/index/BundleContextInterceptor.java
(original)
+++ felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/impl/index/BundleContextInterceptor.java
Wed Mar 19 13:21:51 2014
@@ -110,7 +110,7 @@ public class BundleContextInterceptor ex
 	        		m_logger.log(Logger.LOG_DEBUG, "Indexed filter exceeds lookup time treshold ("
+ duration + "ms.): " + clazz + " " + filter);
 	        	}
             }
-            if (result == null || result.size() == 0) {
+            if (result.size() == 0) {
                 return null;
             }
             return (ServiceReference[]) result.toArray(new ServiceReference[result.size()]);

Modified: felix/sandbox/pderop/dependencymanager-prototype/dm/test/test/SerialExecutorTest.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/dm/test/test/SerialExecutorTest.java?rev=1579223&r1=1579222&r2=1579223&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager-prototype/dm/test/test/SerialExecutorTest.java
(original)
+++ felix/sandbox/pderop/dependencymanager-prototype/dm/test/test/SerialExecutorTest.java
Wed Mar 19 13:21:51 2014
@@ -47,13 +47,14 @@ public class SerialExecutorTest extends 
             System.out.println("Performed " + TESTS + " tests in " + (now - timeStamp) +
" ms.");
             timeStamp = now;
         }
-
         catch (Throwable t) {
             t.printStackTrace();
             Assert.fail("Test failed: " + t.getMessage());
         }
         finally {
-            shutdown(threadPool);
+        	if (threadPool != null) {
+        		shutdown(threadPool);
+        	}
         }
     }
 

Modified: felix/sandbox/pderop/dependencymanager-prototype/dm/test/test/ServiceRaceTest.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/dm/test/test/ServiceRaceTest.java?rev=1579223&r1=1579222&r2=1579223&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager-prototype/dm/test/test/ServiceRaceTest.java (original)
+++ felix/sandbox/pderop/dependencymanager-prototype/dm/test/test/ServiceRaceTest.java Wed
Mar 19 13:21:51 2014
@@ -183,7 +183,7 @@ public class ServiceRaceTest extends Tes
 
     public class Client {
         final Ensure m_step;
-        volatile int m_dependencies;
+        int m_dependencies;
         volatile Dictionary m_conf;
         
         public Client(Ensure step) {
@@ -200,14 +200,14 @@ public class ServiceRaceTest extends Tes
             }
         }
         
-        void add() {
+        synchronized void add() {
             m_step.step();
-            m_dependencies ++;
+            m_dependencies++;
         }
         
-        void remove() {
+        synchronized void remove() {
             m_step.step();
-            m_dependencies --;
+            m_dependencies--;
         }
                 
         void start() {
@@ -222,7 +222,7 @@ public class ServiceRaceTest extends Tes
             m_step.step((DEPENDENCIES + 1) /* deps + conf */ + 1 /* start */ + 1 /* stop
*/  + 1 /* destroy */);
         }
         
-        int getDependencies() {
+        synchronized int getDependencies() {
             return m_dependencies;
         }
         



Mime
View raw message