ReceivePack: catch InvalidObjectIdException while parsing shallow
The "shallow $id" parsing can also throw InvalidObjectIdException, just like parseCommand. Move it into its own method with a proper try-catch block to convert to the checked PackProtocolException. Change-Id: I6839b95f0bc4fbf4d2c213331ebb9bd24ab2af65
This commit is contained in:
parent
0373180321
commit
a1bedf0822
|
@ -1093,7 +1093,7 @@ protected void recvCommands() throws IOException {
|
|||
}
|
||||
|
||||
if (line.length() >= 48 && line.startsWith("shallow ")) { //$NON-NLS-1$
|
||||
clientShallowCommits.add(ObjectId.fromString(line.substring(8, 48)));
|
||||
parseShallow(line.substring(8, 48));
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -1133,6 +1133,16 @@ protected void recvCommands() throws IOException {
|
|||
}
|
||||
}
|
||||
|
||||
private void parseShallow(String idStr) throws PackProtocolException {
|
||||
ObjectId id;
|
||||
try {
|
||||
id = ObjectId.fromString(idStr);
|
||||
} catch (InvalidObjectIdException e) {
|
||||
throw new PackProtocolException(e.getMessage(), e);
|
||||
}
|
||||
clientShallowCommits.add(id);
|
||||
}
|
||||
|
||||
static ReceiveCommand parseCommand(String line) throws PackProtocolException {
|
||||
if (line == null || line.length() < 83) {
|
||||
throw new PackProtocolException(
|
||||
|
|
Loading…
Reference in New Issue