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:
parent
d7377877e0
commit
d8b9c5145b
|
@ -254,6 +254,7 @@ public Set<String> getCapabilities() {
|
||||||
|
|
||||||
private PushCertificateParser pushCertificateParser;
|
private PushCertificateParser pushCertificateParser;
|
||||||
private SignedPushConfig signedPushConfig;
|
private SignedPushConfig signedPushConfig;
|
||||||
|
private PushCertificate pushCert;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the push certificate used to verify the pusher's identity.
|
* 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
|
* @return the parsed certificate, or null if push certificates are disabled
|
||||||
* or no cert was presented by the client.
|
* or no cert was presented by the client.
|
||||||
* @throws IOException if the certificate was present but invalid.
|
|
||||||
* @since 4.1
|
* @since 4.1
|
||||||
*/
|
*/
|
||||||
public PushCertificate getPushCertificate() throws IOException {
|
public PushCertificate getPushCertificate() {
|
||||||
return getPushCertificateParser().build();
|
return pushCert;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1117,6 +1117,7 @@ protected void recvCommands() throws IOException {
|
||||||
certParser.addCommand(cmd);
|
certParser.addCommand(cmd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
pushCert = certParser.build();
|
||||||
} catch (PackProtocolException e) {
|
} catch (PackProtocolException e) {
|
||||||
sendError(e.getMessage());
|
sendError(e.getMessage());
|
||||||
throw e;
|
throw e;
|
||||||
|
|
Loading…
Reference in New Issue