diff --git a/jps/jps-builders/src/org/jetbrains/jps/incremental/BuildOperations.java b/jps/jps-builders/src/org/jetbrains/jps/incremental/BuildOperations.java index 1a25b32c3bbd..8e24d725aeeb 100644 --- a/jps/jps-builders/src/org/jetbrains/jps/incremental/BuildOperations.java +++ b/jps/jps-builders/src/org/jetbrains/jps/incremental/BuildOperations.java @@ -169,9 +169,12 @@ public class BuildOperations { final Collection outputs = srcToOut.getOutputs(srcPath); if (outputs != null) { final boolean shouldPruneOutputDirs = target instanceof ModuleBasedTarget; + final List deletedForThisSource = new ArrayList(outputs.size()); for (String output : outputs) { - deleteRecursively(output, deletedPaths, shouldPruneOutputDirs ? dirsToDelete : null); + deleteRecursively(output, deletedForThisSource, shouldPruneOutputDirs ? dirsToDelete : null); } + deletedPaths.addAll(deletedForThisSource); + dataManager.getOutputToSourceRegistry().removeMapping(deletedForThisSource, srcPath); Set cleaned = cleanedSources.get(target); if (cleaned == null) { cleaned = new THashSet(FileUtil.FILE_HASHING_STRATEGY); diff --git a/jps/jps-builders/src/org/jetbrains/jps/incremental/storage/BuildDataManager.java b/jps/jps-builders/src/org/jetbrains/jps/incremental/storage/BuildDataManager.java index 47d6a7c13800..f836c410290b 100644 --- a/jps/jps-builders/src/org/jetbrains/jps/incremental/storage/BuildDataManager.java +++ b/jps/jps-builders/src/org/jetbrains/jps/incremental/storage/BuildDataManager.java @@ -440,9 +440,7 @@ public class BuildDataManager implements StorageOwner { myDelegate.remove(srcPath); } finally { - for (String output : outputs) { - myOutputToSourceRegistry.removeMapping(output, srcPath); - } + myOutputToSourceRegistry.removeMapping(outputs, srcPath); } } diff --git a/jps/jps-builders/src/org/jetbrains/jps/incremental/storage/OutputToSourceRegistry.java b/jps/jps-builders/src/org/jetbrains/jps/incremental/storage/OutputToSourceRegistry.java index a4568d8c913d..a52fe115dff0 100644 --- a/jps/jps-builders/src/org/jetbrains/jps/incremental/storage/OutputToSourceRegistry.java +++ b/jps/jps-builders/src/org/jetbrains/jps/incremental/storage/OutputToSourceRegistry.java @@ -81,25 +81,32 @@ public class OutputToSourceRegistry extends AbstractStateStorage outputPaths, String sourcePath) throws IOException { + if (outputPaths.isEmpty()) { + return; + } + final int value = FileUtil.pathHashCode(sourcePath); + for (String outputPath : outputPaths) { + final int key = FileUtil.pathHashCode(outputPath); + synchronized (myDataLock) { + final TIntHashSet state = getState(key); + if (state != null) { + final boolean removed = state.remove(value); + if (state.isEmpty()) { + remove(key); + } + else { + if (removed) { + update(key, state); + } } } - return removed; } } - return false; } public Collection getSafeToDeleteOutputs(Collection outputPaths, String associatedSourcePath) throws IOException {