Add shutdown hook to cleanup unfinished clone when JVM is killed
Bug: 516303 Change-Id: I5181b0e8096af3537296848ac7dd74dff0b6d279 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
This commit is contained in:
parent
09d96f8d46
commit
9f98d3e2e4
|
@ -183,6 +183,8 @@ public Git call() throws GitAPIException, InvalidRemoteException,
|
|||
}
|
||||
Repository repository = null;
|
||||
FetchResult fetchResult = null;
|
||||
Thread cleanupHook = new Thread(() -> cleanup());
|
||||
Runtime.getRuntime().addShutdownHook(cleanupHook);
|
||||
try {
|
||||
repository = init();
|
||||
fetchResult = fetch(repository, u);
|
||||
|
@ -205,6 +207,8 @@ public Git call() throws GitAPIException, InvalidRemoteException,
|
|||
}
|
||||
cleanup();
|
||||
throw e;
|
||||
} finally {
|
||||
Runtime.getRuntime().removeShutdownHook(cleanupHook);
|
||||
}
|
||||
if (!noCheckout) {
|
||||
try {
|
||||
|
|
Loading…
Reference in New Issue