]> source.dussan.org Git - jgit.git/commitdiff
BaseReceivePack: Don't throw from getPushCertificate() 20/52020/1
authorDave Borowitz <dborowitz@google.com>
Thu, 16 Jul 2015 00:55:17 +0000 (17:55 -0700)
committerDave Borowitz <dborowitz@google.com>
Thu, 16 Jul 2015 01:09:42 +0000 (18:09 -0700)
Rather than lazily parsing the push in this method, parse it at the
end of recvCommands(), which already contains the necessary try/catch
for handling this error. This allows later callers to avoid having to
handle this condition superfluously.

Change-Id: I5dcaf1a44bf4e321adc281e3381e7e17ac89db06

org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseReceivePack.java

index 518a3178f664c27248df72f9f4bbd84789c9b833..ca287f8bfb251e4d998fa7243080660597ed0dea 100644 (file)
@@ -254,6 +254,7 @@ public abstract class BaseReceivePack {
 
        private PushCertificateParser pushCertificateParser;
        private SignedPushConfig signedPushConfig;
+       private PushCertificate pushCert;
 
        /**
         * Get the push certificate used to verify the pusher's identity.
@@ -262,11 +263,10 @@ public abstract class BaseReceivePack {
         *
         * @return the parsed certificate, or null if push certificates are disabled
         *         or no cert was presented by the client.
-        * @throws IOException if the certificate was present but invalid.
         * @since 4.1
         */
-       public PushCertificate getPushCertificate() throws IOException {
-               return getPushCertificateParser().build();
+       public PushCertificate getPushCertificate() {
+               return pushCert;
        }
 
        /**
@@ -1117,6 +1117,7 @@ public abstract class BaseReceivePack {
                                        certParser.addCommand(cmd);
                                }
                        }
+                       pushCert = certParser.build();
                } catch (PackProtocolException e) {
                        sendError(e.getMessage());
                        throw e;