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
This commit is contained in:
Matthias Sohn 2023-05-18 12:02:48 +02:00
parent 4562e79e23
commit 2cbf0c1774
3 changed files with 9 additions and 3 deletions

View File

@ -1723,6 +1723,11 @@ private void parallelDeltaSearch(ProgressMonitor monitor,
}
throw new IOException(JGitText
.get().packingCancelledDuringObjectsWriting, e);
} catch (Throwable e) {
if (e1 != null) {
e.addSuppressed(e1);
}
throw e;
}
}
}

View File

@ -111,7 +111,7 @@ void execute(ProgressMonitor monitor, FetchResult result,
for (PackLock lock : packLocks) {
lock.unlock();
}
} catch (IOException e) {
} catch (Throwable e) {
if (e1 != null) {
e.addSuppressed(e1);
}

View File

@ -530,9 +530,10 @@ private boolean downloadPackedObject(final ProgressMonitor monitor,
// 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);
}