diff -r 966826542403 parsing.api/src/org/netbeans/modules/parsing/impl/indexing/CacheFolder.java --- a/parsing.api/src/org/netbeans/modules/parsing/impl/indexing/CacheFolder.java Thu Jan 26 22:35:21 2012 +0100 +++ b/parsing.api/src/org/netbeans/modules/parsing/impl/indexing/CacheFolder.java Mon Jan 30 14:39:21 2012 +0100 @@ -57,6 +57,7 @@ import java.util.logging.Logger; import org.openide.filesystems.FileObject; import org.openide.filesystems.FileSystem; +import org.openide.filesystems.FileSystem.AtomicAction; import org.openide.filesystems.FileUtil; import org.openide.filesystems.URLMapper; import org.openide.modules.Places; @@ -156,32 +157,7 @@ final FileObject [] dataFolder = new FileObject[] { null }; // #170182 - preventing filesystem events being fired from under the CacheFolder.class lock - _cacheFolder.getFileSystem().runAtomicAction(new FileSystem.AtomicAction() { - public void run() throws IOException { - synchronized (CacheFolder.class) { - loadSegments(_cacheFolder); - final String rootName = root.toExternalForm(); - String slice = invertedSegments.get (rootName); - if ( slice == null) { - if (onlyIfAlreadyExists) { - return; - } - slice = SLICE_PREFIX + (++index); - while (segments.getProperty(slice) != null) { - slice = SLICE_PREFIX + (++index); - } - segments.put (slice,rootName); - invertedSegments.put(rootName, slice); - storeSegments(_cacheFolder); - } - if (onlyIfAlreadyExists) { - dataFolder[0] = _cacheFolder.getFileObject(slice); - } else { - dataFolder[0] = FileUtil.createFolder(_cacheFolder, slice); - } - } - } - }); + _cacheFolder.getFileSystem().runAtomicAction(new AsyncRefreshAtomicActionImpl(_cacheFolder, root, onlyIfAlreadyExists, dataFolder)); return dataFolder[0]; } @@ -243,4 +219,44 @@ private CacheFolder() { // no-op } + + private static class AsyncRefreshAtomicActionImpl implements AtomicAction { + + private final FileObject _cacheFolder; + private final URL root; + private final boolean onlyIfAlreadyExists; + private final FileObject[] dataFolder; + + public AsyncRefreshAtomicActionImpl(FileObject _cacheFolder, URL root, boolean onlyIfAlreadyExists, FileObject[] dataFolder) { + this._cacheFolder = _cacheFolder; + this.root = root; + this.onlyIfAlreadyExists = onlyIfAlreadyExists; + this.dataFolder = dataFolder; + } + + public void run() throws IOException { + synchronized (CacheFolder.class) { + loadSegments(_cacheFolder); + final String rootName = root.toExternalForm(); + String slice = invertedSegments.get (rootName); + if ( slice == null) { + if (onlyIfAlreadyExists) { + return; + } + slice = SLICE_PREFIX + (++index); + while (segments.getProperty(slice) != null) { + slice = SLICE_PREFIX + (++index); + } + segments.put (slice,rootName); + invertedSegments.put(rootName, slice); + storeSegments(_cacheFolder); + } + if (onlyIfAlreadyExists) { + dataFolder[0] = _cacheFolder.getFileObject(slice); + } else { + dataFolder[0] = FileUtil.createFolder(_cacheFolder, slice); + } + } + } + } }