]> source.dussan.org Git - jgit.git/commitdiff
transport: Move handling code to the caller side 54/152354/2
authorMasaya Suzuki <masayasuzuki@google.com>
Fri, 8 Nov 2019 01:15:57 +0000 (17:15 -0800)
committerMasaya Suzuki <masayasuzuki@google.com>
Mon, 2 Dec 2019 20:25:03 +0000 (12:25 -0800)
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>
org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/ReceivePackAdvertiseRefsHookTest.java
org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java

index 89ac2fe96dd85bba5c3e4396acfbedbe49b54394..daf7b9fb7af0a446aa2386792e27082a4ad78e0e 100644 (file)
@@ -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);
index 16fbbd42f374d819b3e45f0156e21ee3ad2cca08..c92c370a024f4f59abe172bd28a9168fd51ef70c 100644 (file)
@@ -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;
                                }
                        }