From 2e225cfcff96dcb668695bd9bbf076d377cb981e Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Tue, 30 Sep 2008 00:47:51 -0700 Subject: [PATCH] ObjectId: Convert StringIndexOutOfBounds to IllegalArgumentException If parsing an ObjectId fromString fails because the string is too short we don't want to throw StringIndexOutOfBoundsException with a trace that leads back to the error handling code; instead we should throw what the caller expects us to throw, which is IllegalArgumentException. Signed-off-by: Shawn O. Pearce Signed-off-by: Robin Rosenberg --- org.spearce.jgit/src/org/spearce/jgit/lib/MutableObjectId.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/MutableObjectId.java b/org.spearce.jgit/src/org/spearce/jgit/lib/MutableObjectId.java index f88d8cb6..5b16345c 100644 --- a/org.spearce.jgit/src/org/spearce/jgit/lib/MutableObjectId.java +++ b/org.spearce.jgit/src/org/spearce/jgit/lib/MutableObjectId.java @@ -161,6 +161,8 @@ public class MutableObjectId extends AnyObjectId { throw new IllegalArgumentException("Invalid id: " + str); } catch (UnsupportedEncodingException e2) { throw new IllegalArgumentException("Invalid id"); + } catch (StringIndexOutOfBoundsException e2) { + throw new IllegalArgumentException("Invalid id"); } } } -- 2.11.4.GIT