Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMasaya Suzuki2019-11-08 01:40:25 +0000
committerMasaya Suzuki2019-12-02 20:33:11 +0000
commit19293add844cdc972153e1f81e0aac32833660ed (patch)
tree653b7bc7a462c956e942b1815556894fcbc88176
parent6bc366576438be839fb6bd95b5fb5dfcb9306846 (diff)
downloadjgit-19293add844cdc972153e1f81e0aac32833660ed.tar.gz
jgit-19293add844cdc972153e1f81e0aac32833660ed.tar.xz
jgit-19293add844cdc972153e1f81e0aac32833660ed.zip
transport: Move exception handler to the caller
Move exception handling code to the caller side. This is a preparation for adding a custom error handler that is similar to UploadPack. Note that `catch (Throwable t)` will not affect the exception spec since Java will do an analysis of rethrown exceptions. See https://docs.oracle.com/javase/8/docs/technotes/guides/language/catch-multiple.html. Change-Id: I973a63d4b079c2cd1402afb3f2956e18b7d5a00c Signed-off-by: Masaya Suzuki <masayasuzuki@google.com>
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java23
1 files changed, 14 insertions, 9 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 c92c370a02..8cafe775a3 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java
@@ -1373,15 +1373,9 @@ public class ReceivePack {
if (hasCommands()) {
readPostCommands(pck);
}
- } catch (PackProtocolException e) {
- discardCommands();
- fatalError(e.getMessage());
- throw e;
- } catch (InputOverLimitIOException e) {
- String msg = JGitText.get().tooManyCommands;
+ } catch (Throwable t) {
discardCommands();
- fatalError(msg);
- throw new PackProtocolException(msg);
+ throw t;
}
}
@@ -2180,7 +2174,18 @@ public class ReceivePack {
getAdvertisedOrDefaultRefs();
if (hasError())
return;
- recvCommands();
+
+ try {
+ recvCommands();
+ } catch (PackProtocolException e) {
+ fatalError(e.getMessage());
+ throw e;
+ } catch (InputOverLimitIOException e) {
+ String msg = JGitText.get().tooManyCommands;
+ fatalError(msg);
+ throw new PackProtocolException(msg);
+ }
+
if (hasCommands()) {
Throwable unpackError = null;
if (needPack()) {

Back to the top