Browse Source

transport: Move handling code to the caller side

This removes a raw IOException at one level. Later we'll add a custom
exception handling mechanism like UploadPack.

Change-Id: I52a7423798c97b032d848351be8b6f144776b017
Signed-off-by: Masaya Suzuki <masayasuzuki@google.com>
stable-5.7
Masaya Suzuki 5 years ago
parent
commit
6bc3665764
  1. 3
      org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/ReceivePackAdvertiseRefsHookTest.java
  2. 21
      org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java

3
org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/ReceivePackAdvertiseRefsHookTest.java

@ -495,8 +495,7 @@ public class ReceivePackAdvertiseRefsHookTest extends LocalDiskRepositoryTestCas
receive(rp, inBuf, outBuf);
fail("Expected UnpackException");
} catch (UnpackException failed) {
Throwable err = failed.getCause();
assertTrue(err instanceof IOException);
// Expected
}
final PacketLineIn r = asPacketLineIn(outBuf);

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

@ -1217,8 +1217,13 @@ public class ReceivePack {
*
* @throws java.io.IOException
* an error occurred during unpacking or connectivity checking.
* @throws LargeObjectException
* an large object needs to be opened for the check.
* @throws SubmoduleValidationException
* fails to validate the submodule.
*/
protected void receivePackAndCheckConnectivity() throws IOException {
protected void receivePackAndCheckConnectivity() throws IOException,
LargeObjectException, SubmoduleValidationException {
receivePack();
if (needCheckConnectivity()) {
checkSubmodules();
@ -1535,7 +1540,8 @@ public class ReceivePack {
|| !getClientShallowCommits().isEmpty();
}
private void checkSubmodules() throws IOException {
private void checkSubmodules() throws IOException, LargeObjectException,
SubmoduleValidationException {
ObjectDatabase odb = db.getObjectDatabase();
if (objectChecker == null) {
return;
@ -1544,12 +1550,8 @@ public class ReceivePack {
AnyObjectId blobId = entry.getBlobId();
ObjectLoader blob = odb.open(blobId, Constants.OBJ_BLOB);
try {
SubmoduleValidator.assertValidGitModulesFile(
new String(blob.getBytes(), UTF_8));
} catch (LargeObjectException | SubmoduleValidationException e) {
throw new IOException(e);
}
SubmoduleValidator.assertValidGitModulesFile(
new String(blob.getBytes(), UTF_8));
}
}
@ -2184,7 +2186,8 @@ public class ReceivePack {
if (needPack()) {
try {
receivePackAndCheckConnectivity();
} catch (IOException | RuntimeException | Error err) {
} catch (IOException | RuntimeException
| SubmoduleValidationException | Error err) {
unpackError = err;
}
}

Loading…
Cancel
Save