diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java index db0d26746..926c35a69 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java @@ -1017,27 +1017,23 @@ else if (requestValidator instanceof AnyRequestValidator) if (!err.isOutput() && err.getMessage() != null) { try { pckOut.writeString("ERR " + err.getMessage() + "\n"); //$NON-NLS-1$ //$NON-NLS-2$ - err.setOutput(); - } catch (Throwable err2) { - // Ignore this secondary failure (and not mark output). + } catch (IOException e) { + err.addSuppressed(e); + throw err; } + err.setOutput(); } throw err; } catch (IOException | RuntimeException | Error err) { - boolean output = false; + String msg = err instanceof PackProtocolException ? err.getMessage() + : JGitText.get().internalServerError; try { - String msg = err instanceof PackProtocolException - ? err.getMessage() - : JGitText.get().internalServerError; pckOut.writeString("ERR " + msg + "\n"); //$NON-NLS-1$ //$NON-NLS-2$ - output = true; - } catch (Throwable err2) { - // Ignore this secondary failure, leave output false. + } catch (IOException e) { + err.addSuppressed(e); + throw err; } - if (output) { - throw new UploadPackInternalServerErrorException(err); - } - throw err; + throw new UploadPackInternalServerErrorException(err); } finally { if (!sendPack && !biDirectionalPipe) { while (0 < rawIn.skip(2048) || 0 <= rawIn.read()) { @@ -2077,31 +2073,26 @@ private void sendPack(PackStatistics.Accumulator accumulator, // This was already reported on (below). throw noPack; } catch (IOException | RuntimeException | Error err) { - if (reportInternalServerErrorOverSideband()) { - throw new UploadPackInternalServerErrorException(err); - } else { + try { + reportInternalServerErrorOverSideband(); + } catch (IOException e) { + err.addSuppressed(e); throw err; } + throw new UploadPackInternalServerErrorException(err); } } else { sendPack(false, req, accumulator, allTags, unshallowCommits, deepenNots); } } - private boolean reportInternalServerErrorOverSideband() { - try { - @SuppressWarnings("resource" /* java 7 */) - SideBandOutputStream err = new SideBandOutputStream( - SideBandOutputStream.CH_ERROR, - SideBandOutputStream.SMALL_BUF, - rawOut); - err.write(Constants.encode(JGitText.get().internalServerError)); - err.flush(); - return true; - } catch (Throwable cannotReport) { - // Ignore the reason. This is a secondary failure. - return false; - } + private void reportInternalServerErrorOverSideband() throws IOException { + @SuppressWarnings("resource" /* java 7 */) + SideBandOutputStream err = new SideBandOutputStream( + SideBandOutputStream.CH_ERROR, SideBandOutputStream.SMALL_BUF, + rawOut); + err.write(Constants.encode(JGitText.get().internalServerError)); + err.flush(); } /**