diff --git a/plugins/git4idea/src/git4idea/commands/GitSimpleHandler.java b/plugins/git4idea/src/git4idea/commands/GitSimpleHandler.java index 988e1326ee09..d47304ad4397 100644 --- a/plugins/git4idea/src/git4idea/commands/GitSimpleHandler.java +++ b/plugins/git4idea/src/git4idea/commands/GitSimpleHandler.java @@ -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); diff --git a/plugins/git4idea/src/git4idea/commands/GitTextHandler.java b/plugins/git4idea/src/git4idea/commands/GitTextHandler.java index eccf539284b6..22838705a3e9 100644 --- a/plugins/git4idea/src/git4idea/commands/GitTextHandler.java +++ b/plugins/git4idea/src/git4idea/commands/GitTextHandler.java @@ -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) { diff --git a/plugins/git4idea/src/git4idea/history/GitHistoryUtils.java b/plugins/git4idea/src/git4idea/history/GitHistoryUtils.java index d6bb88ff29f1..48506c06ef83 100644 --- a/plugins/git4idea/src/git4idea/history/GitHistoryUtils.java +++ b/plugins/git4idea/src/git4idea/history/GitHistoryUtils.java @@ -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();