Skip to content

Commit

Permalink
javac ast indices: do not throw exceptions to javac internals 2
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmitry Batkovich committed Feb 20, 2017
1 parent d2a23cb commit be01ebb
Showing 1 changed file with 9 additions and 6 deletions.
Expand Up @@ -116,17 +116,20 @@ public PersistentStringEnumerator getFilePathEnumerator() {

public void close() {
myLowMemoryWatcher.stop();
final CommonProcessors.FindFirstProcessor<BuildDataCorruptedException> exceptionProc =
final CommonProcessors.FindFirstProcessor<Exception> exceptionProc =
new CommonProcessors.FindFirstProcessor<>();
close(myFilePathEnumerator, exceptionProc);
close(myNameEnumerator, exceptionProc);
for (InvertedIndex<?, ?, CompiledFileData> index : myIndices.values()) {
close(index, exceptionProc);
}
final BuildDataCorruptedException exception = exceptionProc.getFoundValue();
final Exception exception = exceptionProc.getFoundValue();
if (exception != null) {
removeIndexFiles(myIndicesDir);
throw exception;
if (myRebuildRequestCause == null) {
throw new RuntimeException(exception);
}
return;
}
if (myRebuildRequestCause != null) {
removeIndexFiles(myIndicesDir);
Expand Down Expand Up @@ -194,16 +197,16 @@ void setRebuildRequestCause(Exception e) {
myRebuildRequestCause = e;
}

private static void close(InvertedIndex<?, ?, CompiledFileData> index, CommonProcessors.FindFirstProcessor<BuildDataCorruptedException> exceptionProcessor) {
private static void close(InvertedIndex<?, ?, CompiledFileData> index, CommonProcessors.FindFirstProcessor<Exception> exceptionProcessor) {
try {
index.dispose();
}
catch (BuildDataCorruptedException e) {
catch (RuntimeException e) {
exceptionProcessor.process(e);
}
}

private static void close(Closeable closeable, Processor<BuildDataCorruptedException> exceptionProcessor) {
private static void close(Closeable closeable, Processor<Exception> exceptionProcessor) {
//noinspection SynchronizationOnLocalVariableOrMethodParameter
synchronized (closeable) {
try {
Expand Down

0 comments on commit be01ebb

Please sign in to comment.