Browse Source

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>
stable-5.7
Masaya Suzuki 5 years ago
parent
commit
19293add84
  1. 21
      org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java

21
org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java

@ -1373,15 +1373,9 @@ public class ReceivePack {
if (hasCommands()) { if (hasCommands()) {
readPostCommands(pck); readPostCommands(pck);
} }
} catch (PackProtocolException e) { } catch (Throwable t) {
discardCommands();
fatalError(e.getMessage());
throw e;
} catch (InputOverLimitIOException e) {
String msg = JGitText.get().tooManyCommands;
discardCommands(); discardCommands();
fatalError(msg); throw t;
throw new PackProtocolException(msg);
} }
} }
@ -2180,7 +2174,18 @@ public class ReceivePack {
getAdvertisedOrDefaultRefs(); getAdvertisedOrDefaultRefs();
if (hasError()) if (hasError())
return; return;
try {
recvCommands(); 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()) { if (hasCommands()) {
Throwable unpackError = null; Throwable unpackError = null;
if (needPack()) { if (needPack()) {

Loading…
Cancel
Save