diff options
author | Shawn Pearce <spearce@spearce.org> | 2016-02-16 15:09:05 -0800 |
---|---|---|
committer | Shawn Pearce <spearce@spearce.org> | 2016-02-16 15:09:05 -0800 |
commit | e7a6e85b95b2665b124f57181d8f9bc29100adce (patch) | |
tree | 228d5ed850c0658aca12f4d3b5fa16b84bd02943 /org.eclipse.jgit/src | |
parent | ff5c756c79d1c10575b927cf3bb2eb1e1fcc391b (diff) | |
download | jgit-e7a6e85b95b2665b124f57181d8f9bc29100adce.tar.gz jgit-e7a6e85b95b2665b124f57181d8f9bc29100adce.zip |
smart HTTP server: Pass along "want X not valid" to client
If the client sends a SHA-1 that the server does not recognize echo
this back to the client with an explicit error message instead of
the generic "internal server error".
This was always the intent of the implementation but it was being
dropped on smart HTTP due to the UploadPackServlet catching the
PackProtocolException, discarding the buffered message UploadPack
meant to send, and sending along a generic message instead.
Change-Id: I8d96b064ec655aef64ac2ef3e01853625af32cd1
Diffstat (limited to 'org.eclipse.jgit/src')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java | 35 |
1 files changed, 14 insertions, 21 deletions
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 101057fb4f..8c1f99d226 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java @@ -742,10 +742,6 @@ public class UploadPack { if (!clientShallowCommits.isEmpty()) walk.assumeShallow(clientShallowCommits); sendPack = negotiate(); - } catch (PackProtocolException err) { - reportErrorDuringNegotiate(err.getMessage()); - throw err; - } catch (ServiceMayNotContinueException err) { if (!err.isOutput() && err.getMessage() != null) { try { @@ -756,15 +752,20 @@ public class UploadPack { } } throw err; - - } catch (IOException err) { - reportErrorDuringNegotiate(JGitText.get().internalServerError); - throw err; - } catch (RuntimeException err) { - reportErrorDuringNegotiate(JGitText.get().internalServerError); - throw err; - } catch (Error err) { - reportErrorDuringNegotiate(JGitText.get().internalServerError); + } catch (IOException | RuntimeException | Error err) { + boolean output = false; + 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. + } + if (output) { + throw new UploadPackInternalServerErrorException(err); + } throw err; } @@ -781,14 +782,6 @@ public class UploadPack { return ids; } - private void reportErrorDuringNegotiate(String msg) { - try { - pckOut.writeString("ERR " + msg + "\n"); //$NON-NLS-1$ //$NON-NLS-2$ - } catch (Throwable err) { - // Ignore this secondary failure. - } - } - private void processShallow() throws IOException { try (DepthWalk.RevWalk depthWalk = new DepthWalk.RevWalk( walk.getObjectReader(), depth)) { |