[teiid-commits] teiid SVN: r2850 - branches/7.1.x/cache-jbosscache/src/main/java/org/teiid/cache/jboss.
teiid-commits at lists.jboss.org
teiid-commits at lists.jboss.org
Tue Jan 18 17:14:35 EST 2011
Author: rareddy
Date: 2011-01-18 17:14:35 -0500 (Tue, 18 Jan 2011)
New Revision: 2850
Modified:
branches/7.1.x/cache-jbosscache/src/main/java/org/teiid/cache/jboss/JBossCache.java
Log:
TEIID-1442: JBC upon clear of cache still keeps the empty nodes with a dummy object around (may be for little while), during this time the size calculations can be wrong. So base the size calculations on the nodes with actual data.
Modified: branches/7.1.x/cache-jbosscache/src/main/java/org/teiid/cache/jboss/JBossCache.java
===================================================================
--- branches/7.1.x/cache-jbosscache/src/main/java/org/teiid/cache/jboss/JBossCache.java 2011-01-18 18:54:42 UTC (rev 2849)
+++ branches/7.1.x/cache-jbosscache/src/main/java/org/teiid/cache/jboss/JBossCache.java 2011-01-18 22:14:35 UTC (rev 2850)
@@ -78,9 +78,12 @@
@Override
public V remove(K key) {
Node<K, V> node = getRootNode();
- Node child = node.getChild(getFqn(key));
+ Fqn<String> fqn = getFqn(key);
+ Node child = node.getChild(fqn);
if (child != null) {
- return (V)child.remove(key);
+ V value = (V)child.remove(key);
+ node.removeChild(fqn);
+ return value;
}
return null;
}
@@ -88,7 +91,14 @@
@Override
public int size() {
Node<K, V> node = getRootNode();
- return node.getChildren().size();
+ int size = 0;
+ Set<Node<K,V>> nodes = new HashSet<Node<K, V>>(node.getChildren());
+ for (Node<K, V> child : nodes) {
+ if (!child.getData().isEmpty()) {
+ size++;
+ }
+ }
+ return size;
}
@Override
More information about the teiid-commits
mailing list