]> source.dussan.org Git - jgit.git/commitdiff
[errorprone] FetchProcess: ensure exception isn't suppressed 70/172970/5
authorMatthias Sohn <matthias.sohn@sap.com>
Sat, 28 Nov 2020 23:34:41 +0000 (00:34 +0100)
committerChristian Halstrick <christian.halstrick@sap.com>
Thu, 17 Dec 2020 16:18:11 +0000 (17:18 +0100)
If TransportException is thrown in the finally block of execute()
ensure that the exception handled in the previous catch block isn't
suppressed.

Change-Id: I670acdfb4d36e7a419a9a79ae9faab2e085a43ee
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
org.eclipse.jgit/src/org/eclipse/jgit/transport/FetchProcess.java

index 0f1892a97e84ed720b9a1e82f86c14b54ddddefb..45adfa6522e62b3294744398b3cf14b05beffe61 100644 (file)
@@ -87,13 +87,20 @@ class FetchProcess {
                packLocks.clear();
                localRefs = null;
 
+               Throwable e1 = null;
                try {
                        executeImp(monitor, result);
+               } catch (NotSupportedException | TransportException err) {
+                       e1 = err;
+                       throw err;
                } finally {
                        try {
                        for (PackLock lock : packLocks)
                                lock.unlock();
                        } catch (IOException e) {
+                               if (e1 != null) {
+                                       e.addSuppressed(e1);
+                               }
                                throw new TransportException(e.getMessage(), e);
                        }
                }