Index: ../../../git/apache/jackrabbit-oak/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/IndexTracker.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- ../../../git/apache/jackrabbit-oak/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/IndexTracker.java	(revision 053b4db9e55154fcc535c9ff2e17896a276d14e0)
+++ ../../../git/apache/jackrabbit-oak/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/IndexTracker.java	(revision )
@@ -18,6 +18,7 @@
 
 import static com.google.common.collect.Lists.newArrayList;
 import static com.google.common.collect.Lists.newArrayListWithCapacity;
+import static com.google.common.collect.Maps.newConcurrentMap;
 import static com.google.common.collect.Maps.newHashMap;
 import static org.apache.jackrabbit.oak.plugins.index.IndexConstants.INDEX_DEFINITIONS_NAME;
 import static org.apache.jackrabbit.oak.plugins.index.IndexConstants.TYPE_PROPERTY_NAME;
@@ -27,6 +28,7 @@
 import java.io.IOException;
 import java.util.List;
 import java.util.Map;
+import java.util.concurrent.ConcurrentMap;
 
 import org.apache.jackrabbit.oak.commons.PathUtils;
 import org.apache.jackrabbit.oak.spi.commit.CompositeEditor;
@@ -49,7 +51,7 @@
 
     private NodeState root = EMPTY_NODE;
 
-    private final Map<String, IndexNode> indices = newHashMap();
+    private final ConcurrentMap<String, IndexNode> indices = newConcurrentMap();
 
     synchronized void close() {
         for (Map.Entry<String, IndexNode> entry : indices.entrySet()) {
@@ -72,21 +74,18 @@
             editors.add(new SubtreeEditor(new DefaultEditor() {
                 @Override
                 public void leave(NodeState before, NodeState after) {
-                    IndexNode index = indices.remove(path);
+                    IndexNode old = indices.get(path);
                     try {
-                        index.close();
-                    } catch (IOException e) {
-                        log.error("Failed to close Lucene index at " + path, e);
-                    }
-
-                    try {
-                        index = IndexNode.open(index.getName(), after);
+                        IndexNode index = IndexNode.open(old.getName(), after);
                         if (index != null) {
                             indices.put(path, index);
+                        } else {
+                            indices.remove(path);
                         }
                     } catch (IOException e) {
                         log.error("Failed to open Lucene index at " + path, e);
                     }
+                    close(old, path);
                 }
             }, elements.toArray(new String[elements.size()])));
         }
@@ -94,12 +93,20 @@
         this.root = root;
     }
 
-    synchronized IndexNode getIndexNode(String path) {
+    IndexNode getIndexNode(String path) {
         IndexNode index = indices.get(path);
         if (index != null) {
             return index;
         }
+        return getIndexNode0(path);
+    }
 
+    private synchronized IndexNode getIndexNode0(String path) {
+        IndexNode index = indices.get(path);
+        if (index != null) {
+            return index;
+        }
+
         NodeState node = root;
         for (String name : PathUtils.elements(path)) {
             node = root.getChildNode(name);
@@ -122,6 +129,14 @@
         }
 
         return null;
+    }
+
+    private static void close(IndexNode index, String path) {
+        try {
+            index.close();
+        } catch (IOException e) {
+            log.error("Failed to close Lucene index at " + path, e);
+        }
     }
 
 }
