BaseReceivePack: Don't throw from getPushCertificate()

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
This commit is contained in:
Dave Borowitz 2015-07-15 17:55:17 -07:00
parent d7377877e0
commit d8b9c5145b
1 changed files with 4 additions and 3 deletions

View File

@ -254,6 +254,7 @@ public Set<String> getCapabilities() {
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 Set<String> getCapabilities() {
*
* @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 @@ protected void recvCommands() throws IOException {
certParser.addCommand(cmd);
}
}
pushCert = certParser.build();
} catch (PackProtocolException e) {
sendError(e.getMessage());
throw e;