You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by bo...@apache.org on 2012/07/16 16:19:37 UTC
svn commit: r1362052 - in
/hadoop/common/trunk/hadoop-common-project/hadoop-common/src:
main/java/org/apache/hadoop/util/StringUtils.java
test/java/org/apache/hadoop/util/TestStringUtils.java
Author: bobby
Date: Mon Jul 16 14:19:36 2012
New Revision: 1362052
URL: http://svn.apache.org/viewvc?rev=1362052&view=rev
Log:
MAPREDUCE-4395. Possible NPE at ClientDistributedCacheManager#determineTimestamps (Bhallamudi via bobby)
Modified:
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/StringUtils.java
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/TestStringUtils.java
Modified: hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/StringUtils.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/StringUtils.java?rev=1362052&r1=1362051&r2=1362052&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/StringUtils.java (original)
+++ hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/StringUtils.java Mon Jul 16 14:19:36 2012
@@ -202,8 +202,12 @@ public class StringUtils {
}
/**
- *
* @param str
+ * The string array to be parsed into an URI array.
+ * @return <tt>null</tt> if str is <tt>null</tt>, else the URI array
+ * equivalent to str.
+ * @throws IllegalArgumentException
+ * If any string in str violates RFC 2396.
*/
public static URI[] stringToURI(String[] str){
if (str == null)
@@ -213,9 +217,8 @@ public class StringUtils {
try{
uris[i] = new URI(str[i]);
}catch(URISyntaxException ur){
- System.out.println("Exception in specified URI's " + StringUtils.stringifyException(ur));
- //making sure its asssigned to null in case of an error
- uris[i] = null;
+ throw new IllegalArgumentException(
+ "Failed to create uri for " + str[i], ur);
}
}
return uris;
Modified: hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/TestStringUtils.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/TestStringUtils.java?rev=1362052&r1=1362051&r2=1362052&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/TestStringUtils.java (original)
+++ hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/TestStringUtils.java Mon Jul 16 14:19:36 2012
@@ -269,6 +269,17 @@ public class TestStringUtils extends Uni
assertEquals("Yy", StringUtils.camelize("yY"));
assertEquals("Zz", StringUtils.camelize("zZ"));
}
+
+ @Test
+ public void testStringToURI() {
+ String[] str = new String[] { "file://" };
+ try {
+ StringUtils.stringToURI(str);
+ fail("Ignoring URISyntaxException while creating URI from string file://");
+ } catch (IllegalArgumentException iae) {
+ assertEquals("Failed to create uri for file://", iae.getMessage());
+ }
+ }
// Benchmark for StringUtils split
public static void main(String []args) {