summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit
diff options
context:
space:
mode:
authorKetan Padegaonkar <KetanPadegaonkar@gmail.com>2011-05-19 13:08:26 +0530
committerChris Aniszczyk <caniszczyk@gmail.com>2011-05-19 08:58:17 -0500
commitf953a35e9a1f279ca038955243c07fd84fb6ae23 (patch)
tree2de64ceafa32ceba88548f59d41dee8fca82094b /org.eclipse.jgit
parentdc30c95d971ca270f442403ada0d4e3b00151419 (diff)
downloadjgit-f953a35e9a1f279ca038955243c07fd84fb6ae23.tar.gz
jgit-f953a35e9a1f279ca038955243c07fd84fb6ae23.zip
Fix NPE in URIish when parsing an empty URI
Change-Id: Id1c42dc9843f62c581b9904b02150de53cf7777c Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/URIish.java5
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/util/StringUtils.java11
2 files changed, 16 insertions, 0 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/URIish.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/URIish.java
index 1c9397922a..8fe7b2aa51 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/URIish.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/URIish.java
@@ -55,6 +55,7 @@ import java.util.regex.Pattern;
import org.eclipse.jgit.JGitText;
import org.eclipse.jgit.lib.Constants;
+import org.eclipse.jgit.util.StringUtils;
/**
* This URI like construct used for referencing Git archives over the net, as
@@ -193,6 +194,10 @@ public class URIish implements Serializable {
* @throws URISyntaxException
*/
public URIish(String s) throws URISyntaxException {
+ if (StringUtils.isEmptyOrNull(s)) {
+ throw new URISyntaxException("The uri was empty or null",
+ JGitText.get().cannotParseGitURIish);
+ }
Matcher matcher = SINGLE_SLASH_FILE_URI.matcher(s);
if (matcher.matches()) {
scheme = matcher.group(1);
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/StringUtils.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/StringUtils.java
index 59f3d83ccf..5e43b26931 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/util/StringUtils.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/StringUtils.java
@@ -222,4 +222,15 @@ public final class StringUtils {
private StringUtils() {
// Do not create instances
}
+
+ /**
+ * Test if a string is empty or null.
+ *
+ * @param stringValue
+ * the string to check
+ * @return <code>true</code> if the string is <code>null</code> or empty
+ */
+ public static boolean isEmptyOrNull(String stringValue) {
+ return stringValue == null || stringValue.length() == 0;
+ }
}