felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From uiter...@apache.org
Subject svn commit: r1535688 - in /felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/tracker: AbstractTracked.java ServiceTracker.java
Date Fri, 25 Oct 2013 11:13:16 GMT
Author: uiterlix
Date: Fri Oct 25 11:13:16 2013
New Revision: 1535688

URL: http://svn.apache.org/r1535688
Log:
Changed map of tracked items to a LinkedHashMap to make the ServiceTracker behavior on close
more deterministic.

Modified:
    felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/tracker/AbstractTracked.java
    felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/tracker/ServiceTracker.java

Modified: felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/tracker/AbstractTracked.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/tracker/AbstractTracked.java?rev=1535688&r1=1535687&r2=1535688&view=diff
==============================================================================
--- felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/tracker/AbstractTracked.java
(original)
+++ felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/tracker/AbstractTracked.java
Fri Oct 25 11:13:16 2013
@@ -17,9 +17,9 @@ package org.apache.felix.dm.tracker;
 
 import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.LinkedHashMap;
 import java.util.LinkedList;
 import java.util.List;
-import java.util.Map;
 
 /**
  * Abstract class to track items. If a Tracker is reused (closed then reopened),
@@ -38,11 +38,12 @@ abstract class AbstractTracked {
 	private static final boolean		DEBUG	= false;
 
 	/**
-	 * Map of tracked items to customized objects.
+	 * Ordered Map of tracked items to customized objects. An ordered map is used to
+	 * provide a predictable order in the getTracked() method.
 	 * 
 	 * @GuardedBy this
 	 */
-	private Map			tracked;
+	private LinkedHashMap			tracked;
 
 	/**
 	 * Modification count. This field is initialized to zero and incremented by
@@ -99,14 +100,14 @@ abstract class AbstractTracked {
 	 * AbstractTracked constructor.
 	 */
 	AbstractTracked() {
-	    this.tracked = new HashMap();
+	    this.tracked = new LinkedHashMap();
 	    trackingCount = 0;
 	    adding = new ArrayList(6);
 	    initial = new LinkedList();
 	    closed = false;
 	}
 	
-	void setTracked(HashMap map) {
+	void setTracked(LinkedHashMap map) {
 	    this.tracked = map;
 	}
 

Modified: felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/tracker/ServiceTracker.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/tracker/ServiceTracker.java?rev=1535688&r1=1535687&r2=1535688&view=diff
==============================================================================
--- felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/tracker/ServiceTracker.java
(original)
+++ felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/tracker/ServiceTracker.java
Fri Oct 25 11:13:16 2013
@@ -20,6 +20,7 @@ import java.security.PrivilegedAction;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Iterator;
+import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
@@ -1356,7 +1357,7 @@ public class ServiceTracker implements S
 			customizer.removedService((ServiceReference) item, object);
 		}
 		
-		class HashMapCache extends HashMap {
+		class HashMapCache extends LinkedHashMap {
 		    public Object put(Object key, Object value) {
 		        addHighestTrackedCache((ServiceReference) key);
 		        return super.put(key, value);



Mime
View raw message