Extract the Maven 2.x layout provider code into a separate module
Another attempt at fixing the the ConcurrentModificationException...
@@ -10,6 +10,7 @@ import javax.inject.Inject;
import java.io.IOException;
import java.util.LinkedHashMap;
import java.util.Map;
+import java.util.concurrent.locks.ReentrantLock;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -33,13 +34,15 @@ public class RepositoryIndexManager
@Inject
private ConfigurationManager configurationManager;
+ private ReentrantLock lock = new ReentrantLock();
+
public RepositoryIndexManager()
{
}
@PreDestroy
- private synchronized void close()
+ private void close()
{
for (String contextId : indexes.keySet())
{
@@ -88,6 +91,10 @@ public class RepositoryIndexManager
public void closeIndexer(String contextId)
throws IOException
+ {
+ lock.lock();
+
+ try
{
final RepositoryIndexer repositoryIndexer = indexes.get(contextId);
@@ -104,6 +111,11 @@ public class RepositoryIndexManager
indexes.remove(contextId);
}
+ finally
+ {
+ lock.unlock();
+ }
+ }
public Map<String, RepositoryIndexer> getIndexes()
{
