Errored out project should have empty classpath

This commit is contained in:
BoykoAlex
2017-11-20 18:15:30 -05:00
parent 08c1cd33ef
commit 1014e90ed3
2 changed files with 8 additions and 2 deletions

View File

@@ -205,6 +205,9 @@ public class DelegatingCachedClasspath<T extends IClasspath> implements IClasspa
return false;
} catch (Exception e) {
cachedData.set(new ClasspathData(null, Collections.emptySet(), Collections.emptySet(), null));
if (cacheFile != null && cacheFile.exists()) {
cacheFile.delete();
}
throw e;
}
}

View File

@@ -32,6 +32,7 @@ import java.nio.file.FileVisitOption;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Comparator;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -84,8 +85,8 @@ public class MavenProjectCacheTest {
Path cacheFolerPath = testProjectPath.resolve(IJavaProject.PROJECT_CACHE_FOLDER);
if (cacheFolerPath.toFile().exists()) {
Files.walk(cacheFolerPath, FileVisitOption.FOLLOW_LINKS).map(Path::toFile).forEach(File::delete);
Files.delete(cacheFolerPath);
Files.walk(cacheFolerPath, FileVisitOption.FOLLOW_LINKS).sorted(Comparator.reverseOrder()).map(Path::toFile)
.forEach(File::delete);
}
}
@@ -252,5 +253,7 @@ public class MavenProjectCacheTest {
}).get(10, TimeUnit.SECONDS);
progressDone.set(false);
verify(diagnosticService, times(1)).diagnosticEvent(any(ShowMessageException.class));
assertTrue(project.getClasspath().getClasspathEntries().isEmpty());
assertFalse(cacheFolder.resolve(DelegatingCachedClasspath.CLASSPATH_DATA_CACHE_FILE).toFile().exists());
}
}