Git: semaphore.up() in startFailed() and in finally block.

This fixes IDEA-75312 and should fix IDEA-75490
This commit is contained in:
Kirill Likhodedov
2011-10-17 16:59:25 +04:00
parent 4478764206
commit a77d0b3f49
3 changed files with 28 additions and 14 deletions
@@ -218,8 +218,11 @@ public class GitSimpleHandler extends GitTextHandler {
}
public void startFailed(final Throwable exception) {
ex[0] = new VcsException("Process failed to start (" + myCommandLine.getCommandLineString() + "): " + exception.toString(), exception);
sem.release();
try {
ex[0] = new VcsException("Process failed to start (" + myCommandLine.getCommandLineString() + "): " + exception.toString(), exception);
} finally {
sem.release();
}
}
});
GitHandlerUtil.runInCurrentThread(this, null);
@@ -68,10 +68,13 @@ public abstract class GitTextHandler extends GitHandler {
public void processTerminated(final ProcessEvent event) {
final int exitCode = event.getExitCode();
setExitCode(exitCode);
cleanupEnv();
GitTextHandler.this.processTerminated(exitCode);
listeners().processTerminated(exitCode);
try {
setExitCode(exitCode);
cleanupEnv();
GitTextHandler.this.processTerminated(exitCode);
} finally {
listeners().processTerminated(exitCode);
}
}
public void processWillTerminate(final ProcessEvent event, final boolean willBeDestroyed) {
@@ -223,6 +223,7 @@ public class GitHistoryUtils {
}
@Override
public void startFailed(Throwable exception) {
semaphore.up();
}
});
semaphore.down();
@@ -356,18 +357,24 @@ public class GitHistoryUtils {
@Override
public void startFailed(Throwable exception) {
//noinspection ThrowableInstanceNeverThrown
exceptionConsumer.consume(new VcsException(exception));
semaphore.up();
try {
exceptionConsumer.consume(new VcsException(exception));
} finally {
semaphore.up();
}
}
@Override
public void processTerminated(int exitCode) {
super.processTerminated(exitCode);
final GitLogRecord record = accumulator.processLast();
if (record != null) {
resultAdapter.consume(record);
try {
super.processTerminated(exitCode);
final GitLogRecord record = accumulator.processLast();
if (record != null) {
resultAdapter.consume(record);
}
} finally {
semaphore.up();
}
semaphore.up();
}
});
semaphore.down();
@@ -607,6 +614,7 @@ public class GitHistoryUtils {
}
@Override
public void startFailed(Throwable exception) {
semaphore.up();
}
});
semaphore.down();
@@ -821,7 +829,7 @@ public class GitHistoryUtils {
@Override
public void startFailed(Throwable exception) {
// todo
semaphore.up();
}
});
semaphore.down();