jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r1199175 - /jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/mem/NodeListSmall.java
Date Tue, 08 Nov 2011 10:20:02 GMT
Author: thomasm
Date: Tue Nov  8 10:20:02 2011
New Revision: 1199175

URL: http://svn.apache.org/viewvc?rev=1199175&view=rev
Log:
Fix a concurrency problem.

Modified:
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/mem/NodeListSmall.java

Modified: jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/mem/NodeListSmall.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/mem/NodeListSmall.java?rev=1199175&r1=1199174&r2=1199175&view=diff
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/mem/NodeListSmall.java
(original)
+++ jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/mem/NodeListSmall.java
Tue Nov  8 10:20:02 2011
@@ -36,7 +36,7 @@ public class NodeListSmall implements No
     String[] names;
     long[] children;
     private int[] sort;
-    private int last;
+    private int lastNameIndexCache;
 
     NodeListSmall() {
         this(EMPTY_STRING_ARRAY, EMPTY_LONG_ARRAY, EMPTY_INTEGER_ARRAY, 0);
@@ -58,6 +58,8 @@ public class NodeListSmall implements No
     }
 
     private int find(String name) {
+        // copy, to avoid concurrency issues
+        int last = lastNameIndexCache;
         if (last < size && names[sort[last]].equals(name)) {
             return last;
         }
@@ -66,7 +68,7 @@ public class NodeListSmall implements No
             int test = (min + max) >>> 1;
             int compare = names[sort[test]].compareTo(name);
             if (compare == 0) {
-                last = test;
+                lastNameIndexCache = test;
                 return test;
             }
             if (compare > 0) {



Mime
View raw message