diff options
author | Matthias Sohn <matthias.sohn@sap.com> | 2020-08-31 02:18:43 +0200 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2020-09-01 17:51:45 +0200 |
commit | 1d95f9cb8f669b162bb8ee6492100f646bef3480 (patch) | |
tree | 78607c0153b430294cdddebe63a7d6e3d0ab80aa /org.eclipse.jgit | |
parent | 04622016ead740da144ba34625bda4692c0aed38 (diff) | |
download | jgit-1d95f9cb8f669b162bb8ee6492100f646bef3480.tar.gz jgit-1d95f9cb8f669b162bb8ee6492100f646bef3480.zip |
[errorprone] PackWriter#parallelDeltaSearch: avoid suppressed exception
See https://errorprone.info/bugpattern/Finally
Change-Id: Ic2ad0d1e1ba7552b5a5c6238f83c0e13a94254d0
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java | 10 |
1 files changed, 9 insertions, 1 deletions
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 2d574887b3..9e409490fa 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 @@ public class PackWriter implements AutoCloseable { 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 @@ public class PackWriter implements AutoCloseable { // 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); } |