diff options
author | Shawn Pearce <spearce@spearce.org> | 2016-07-05 13:00:02 -0700 |
---|---|---|
committer | Shawn Pearce <spearce@spearce.org> | 2016-07-05 17:17:50 -0700 |
commit | a1bedf08228350733a6dd9c2c8c0c9053efbbcec (patch) | |
tree | cc0b906fc1be43fe597ee96ce651a0116c33ea4e | |
parent | 0373180321f6b06d50b44017f462cf2297c1e209 (diff) | |
download | jgit-a1bedf08228350733a6dd9c2c8c0c9053efbbcec.tar.gz jgit-a1bedf08228350733a6dd9c2c8c0c9053efbbcec.zip |
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
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseReceivePack.java | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseReceivePack.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseReceivePack.java index 9792df4d1a..f4eef5f48e 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseReceivePack.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseReceivePack.java @@ -1093,7 +1093,7 @@ public abstract class BaseReceivePack { } 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 @@ public abstract class BaseReceivePack { } } + 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( |