diff options
author | Masaya Suzuki <masayasuzuki@google.com> | 2019-11-08 10:31:16 -0800 |
---|---|---|
committer | Masaya Suzuki <masayasuzuki@google.com> | 2019-12-02 14:09:55 -0800 |
commit | e75e95e5352b790e542898b1cad8fc7230246447 (patch) | |
tree | f163672244260242763c6ed935c7e0af7434b35b /org.eclipse.jgit | |
parent | 6ccff81428d1df0b020db43268e845cb4ab7ed46 (diff) | |
download | jgit-e75e95e5352b790e542898b1cad8fc7230246447.tar.gz jgit-e75e95e5352b790e542898b1cad8fc7230246447.zip |
transport: Add methods that do not handle exceptions
Same as UploadPack. These methods do not handle exceptions and the
caller can handle them. This makes it possible to customize the error
handling.
Change-Id: Ia5203f80133cb5b3e5d754859b4167ac920eaf14
Signed-off-by: Masaya Suzuki <masayasuzuki@google.com>
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java | 54 |
1 files changed, 44 insertions, 10 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java index 94cfe6c0a3..6de3848d8e 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java @@ -2194,6 +2194,49 @@ public class ReceivePack { init(input, output, messages); try { service(); + } catch (PackProtocolException e) { + fatalError(e.getMessage()); + throw e; + } catch (InputOverLimitIOException e) { + String msg = JGitText.get().tooManyCommands; + fatalError(msg); + throw new PackProtocolException(msg); + } finally { + try { + close(); + } finally { + release(); + } + } + } + + /** + * Execute the receive task on the socket. + * + * <p> + * Same as {@link #receive}, but the exceptions are not reported to the + * client yet. + * + * @param input + * raw input to read client commands and pack data from. Caller + * must ensure the input is buffered, otherwise read performance + * may suffer. + * @param output + * response back to the Git network client. Caller must ensure + * the output is buffered, otherwise write performance may + * suffer. + * @param messages + * secondary "notice" channel to send additional messages out + * through. When run over SSH this should be tied back to the + * standard error channel of the command execution. For most + * other network connections this should be null. + * @throws java.io.IOException + */ + public void receiveWithExceptionPropagation(InputStream input, + OutputStream output, OutputStream messages) throws IOException { + init(input, output, messages); + try { + service(); } finally { try { close(); @@ -2212,16 +2255,7 @@ public class ReceivePack { if (hasError()) return; - try { - recvCommands(); - } catch (PackProtocolException e) { - fatalError(e.getMessage()); - throw e; - } catch (InputOverLimitIOException e) { - String msg = JGitText.get().tooManyCommands; - fatalError(msg); - throw new PackProtocolException(msg); - } + recvCommands(); if (hasCommands()) { try (PostReceiveExecutor e = new PostReceiveExecutor()) { |