[errorprone] FetchProcess: ensure exception isn't suppressed

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>
This commit is contained in:
Matthias Sohn 2020-11-29 00:34:41 +01:00 committed by Christian Halstrick
parent 9680407e45
commit c8c0556f76
1 changed files with 7 additions and 0 deletions

View File

@ -87,13 +87,20 @@ void execute(ProgressMonitor monitor, FetchResult result)
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);
}
}