MAPREDUCE-4395. Possible NPE at ClientDistributedCacheManager#determineTimestamps (Bhallamudi via bobby)

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1362052 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Joseph Evans 2012-07-16 14:19:36 +00:00
parent 0f122c209d
commit 612443951b
3 changed files with 21 additions and 4 deletions

View File

@ -202,8 +202,12 @@ public class StringUtils {
} }
/** /**
*
* @param str * @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&nbsp;2396.
*/ */
public static URI[] stringToURI(String[] str){ public static URI[] stringToURI(String[] str){
if (str == null) if (str == null)
@ -213,9 +217,8 @@ public class StringUtils {
try{ try{
uris[i] = new URI(str[i]); uris[i] = new URI(str[i]);
}catch(URISyntaxException ur){ }catch(URISyntaxException ur){
System.out.println("Exception in specified URI's " + StringUtils.stringifyException(ur)); throw new IllegalArgumentException(
//making sure its asssigned to null in case of an error "Failed to create uri for " + str[i], ur);
uris[i] = null;
} }
} }
return uris; return uris;

View File

@ -270,6 +270,17 @@ public class TestStringUtils extends UnitTestcaseTimeLimit {
assertEquals("Zz", StringUtils.camelize("zZ")); 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 // Benchmark for StringUtils split
public static void main(String []args) { public static void main(String []args) {
final String TO_SPLIT = "foo,bar,baz,blah,blah"; final String TO_SPLIT = "foo,bar,baz,blah,blah";

View File

@ -236,6 +236,9 @@ Branch-2 ( Unreleased changes )
HADOOP-8499. Lower min.user.id to 500 for the tests. HADOOP-8499. Lower min.user.id to 500 for the tests.
(Colin Patrick McCabe via eli) (Colin Patrick McCabe via eli)
MAPREDUCE-4395. Possible NPE at ClientDistributedCacheManager
#determineTimestamps (Bhallamudi via bobby)
Release 2.0.0-alpha - 05-23-2012 Release 2.0.0-alpha - 05-23-2012
INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES