]> source.dussan.org Git - jgit.git/commitdiff
[errorprone] WalkFetchConnection: ensure exception isn't suppressed 69/172969/5
authorMatthias Sohn <matthias.sohn@sap.com>
Sat, 28 Nov 2020 23:29:08 +0000 (00:29 +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
downloadPackedObject() ensure that the exception handled in the previous
catch block isn't suppressed.

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

index c44838ab89d1a7493b1caddfbb136bd2729114d0..a6b20451ddbb80d8c835715c0927125cfb259aea 100644 (file)
@@ -510,6 +510,7 @@ class WalkFetchConnection extends BaseFetchConnection {
                        // and attach it to the local repository so we can use
                        // all of the contained objects.
                        //
+                       Throwable e1 = null;
                        try {
                                pack.downloadPack(monitor);
                        } catch (IOException err) {
@@ -519,6 +520,7 @@ class WalkFetchConnection extends BaseFetchConnection {
                                // an alternate.
                                //
                                recordError(id, err);
+                               e1 = err;
                                continue;
                        } finally {
                                // If the pack was good its in the local repository
@@ -531,6 +533,9 @@ class WalkFetchConnection extends BaseFetchConnection {
                                        if (pack.tmpIdx != null)
                                                FileUtils.delete(pack.tmpIdx);
                                } catch (IOException e) {
+                                       if (e1 != null) {
+                                               e.addSuppressed(e1);
+                                       }
                                        throw new TransportException(e.getMessage(), e);
                                }
                                packItr.remove();