diff options
author | Matthias Sohn <matthias.sohn@sap.com> | 2023-05-18 12:02:48 +0200 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2023-05-18 21:10:33 +0200 |
commit | 2cbf0c1774ed0529fc4910c768452902e346ff23 (patch) | |
tree | 2bc13ab42e4bb10e3e91e954441dd8913c76ef00 /org.eclipse.jgit/src | |
parent | 4562e79e234696ae3e1601db9bf8b73a1ef7edf8 (diff) | |
download | jgit-2cbf0c1774ed0529fc4910c768452902e346ff23.tar.gz jgit-2cbf0c1774ed0529fc4910c768452902e346ff23.zip |
Also add suppressed exception if unchecked exception occurs in finally
If a method called in a finally block throws an exception we should add
exceptions caught earlier to the exception we throw in the finally block
not regarding if it's a checked or unchecked exception.
Change-Id: I4c6be9a3a08482b07659ca31d6987ce719d81ca5
Diffstat (limited to 'org.eclipse.jgit/src')
3 files changed, 9 insertions, 3 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 666e9d8cbc..9508f3fe39 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 @@ -1723,6 +1723,11 @@ public class PackWriter implements AutoCloseable { } throw new IOException(JGitText .get().packingCancelledDuringObjectsWriting, e); + } catch (Throwable e) { + if (e1 != null) { + e.addSuppressed(e1); + } + throw e; } } } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/FetchProcess.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/FetchProcess.java index f02160e457..c510194ee6 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/FetchProcess.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/FetchProcess.java @@ -111,7 +111,7 @@ class FetchProcess { for (PackLock lock : packLocks) { lock.unlock(); } - } catch (IOException e) { + } catch (Throwable e) { if (e1 != null) { e.addSuppressed(e1); } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/WalkFetchConnection.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/WalkFetchConnection.java index ed8f450c53..cc6c252fa1 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/WalkFetchConnection.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/WalkFetchConnection.java @@ -530,9 +530,10 @@ class WalkFetchConnection extends BaseFetchConnection { // are unusable and we shouldn't consult them again. // try { - if (pack.tmpIdx != null) + if (pack.tmpIdx != null) { FileUtils.delete(pack.tmpIdx); - } catch (IOException e) { + } + } catch (Throwable e) { if (e1 != null) { e.addSuppressed(e1); } |