[JGIT PATCH 2/2] ObjectId: Convert StringIndexOutOfBounds to IllegalArgumentException

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <spearce@xxxxxxxxxxx>
---
 .../src/org/spearce/jgit/lib/MutableObjectId.java  |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

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 f88d8cb..5b16345 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 @@ private void fromHexString(final byte[] bs, int p) {
 				throw new IllegalArgumentException("Invalid id: " + str);
 			} catch (UnsupportedEncodingException e2) {
 				throw new IllegalArgumentException("Invalid id");
+			} catch (StringIndexOutOfBoundsException e2) {
+				throw new IllegalArgumentException("Invalid id");
 			}
 		}
 	}
-- 
1.6.0.2.463.g7f0eb

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux