[errorprone] PackWriter#parallelDeltaSearch: avoid suppressed exception
See https://errorprone.info/bugpattern/Finally
Change-Id: Ic2ad0d1e1ba7552b5a5c6238f83c0e13a94254d0
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java
index 2d57488..9e40949 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java
@@ -1548,6 +1548,7 @@
endPhase(monitor);
}
+ @SuppressWarnings("Finally")
private void parallelDeltaSearch(ProgressMonitor monitor,
ObjectToPack[] list, int cnt, int threads) throws IOException {
DeltaCache dc = new ThreadSafeDeltaCache(config);
@@ -1569,15 +1570,22 @@
// Caller didn't give us a way to run the tasks, spawn up a
// temporary thread pool and make sure it tears down cleanly.
ExecutorService pool = Executors.newFixedThreadPool(threads);
+ Throwable e1 = null;
try {
runTasks(pool, pm, taskBlock, errors);
+ } catch (Exception e) {
+ e1 = e;
} finally {
pool.shutdown();
for (;;) {
try {
- if (pool.awaitTermination(60, TimeUnit.SECONDS))
+ if (pool.awaitTermination(60, TimeUnit.SECONDS)) {
break;
+ }
} catch (InterruptedException e) {
+ if (e1 != null) {
+ e.addSuppressed(e1);
+ }
throw new IOException(JGitText
.get().packingCancelledDuringObjectsWriting, e);
}