From cd528f1ab0e1b5c6d4c02c8df53995532694b707 Mon Sep 17 00:00:00 2001 From: nik Date: Wed, 11 Aug 2010 09:34:52 +0400 Subject: [PATCH] IDEA-57345: "Error: null" during make (NPE in ArtifactsCompilerInstance.deleteFiles) --- .../impl/generic/GenericCompilerCache.java | 2 +- .../com/intellij/util/io/PersistentHashMap.java | 17 +++++++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/java/compiler/impl/src/com/intellij/compiler/impl/generic/GenericCompilerCache.java b/java/compiler/impl/src/com/intellij/compiler/impl/generic/GenericCompilerCache.java index 9217bde65a71..6b3f4c3fbd53 100644 --- a/java/compiler/impl/src/com/intellij/compiler/impl/generic/GenericCompilerCache.java +++ b/java/compiler/impl/src/com/intellij/compiler/impl/generic/GenericCompilerCache.java @@ -80,7 +80,7 @@ public class GenericCompilerCache { } public void processSources(final int targetId, final Processor processor) throws IOException { - myPersistentMap.processKeys(new Processor>() { + myPersistentMap.processKeysWithExistingMapping(new Processor>() { @Override public boolean process(KeyAndTargetData data) { return targetId == data.myTarget ? processor.process(data.myKey) : true; diff --git a/platform/util/src/com/intellij/util/io/PersistentHashMap.java b/platform/util/src/com/intellij/util/io/PersistentHashMap.java index ef47ffd844a3..40e9af21f66d 100644 --- a/platform/util/src/com/intellij/util/io/PersistentHashMap.java +++ b/platform/util/src/com/intellij/util/io/PersistentHashMap.java @@ -17,6 +17,7 @@ package com.intellij.util.io; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.util.io.FileUtil; +import com.intellij.util.CommonProcessors; import com.intellij.util.Processor; import com.intellij.util.containers.LimitedPool; import com.intellij.util.containers.SLRUCache; @@ -24,7 +25,9 @@ import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import java.io.*; +import java.util.ArrayList; import java.util.Collection; +import java.util.List; /** * @author Eugene Zhuravlev @@ -213,6 +216,10 @@ public class PersistentHashMap extends PersistentEnumerator{ } } + /** + * Process all keys registered in the map. Note that keys which were removed after {@link #compact()} call will be processed as well. Use + * {@link #processKeysWithExistingMapping(com.intellij.util.Processor)} to process only keys with existing mappings + */ public synchronized boolean processKeys(Processor processor) throws IOException { synchronized (ourLock) { myAppendCache.clear(); @@ -220,9 +227,15 @@ public class PersistentHashMap extends PersistentEnumerator{ } } - public synchronized Collection getAllKeysWithExistingMapping() throws IOException { + public Collection getAllKeysWithExistingMapping() throws IOException { + final List values = new ArrayList(); + processKeysWithExistingMapping(new CommonProcessors.CollectProcessor(values)); + return values; + } + + public synchronized boolean processKeysWithExistingMapping(Processor processor) throws IOException { synchronized (ourLock) { - return getAllDataObjects(new DataFilter() { + return processAllDataObject(processor, new DataFilter() { public boolean accept(final int id) { try { return readValueId(id).address != NULL_ADDR;