HADOOP-7851. Configuration.getClasses() never returns the default value. (amarrk)
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1212282 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
066cddb44e
commit
82d57ee7fe
@ -75,6 +75,8 @@ Trunk (unreleased changes)
|
||||
HADOOP-7886. Add toString to FileStatus. (SreeHari via jghoman)
|
||||
|
||||
BUGS
|
||||
HADOOP-7851. Configuration.getClasses() never returns the default value.
|
||||
(amarrk)
|
||||
|
||||
HADOOP-7606. Upgrade Jackson to version 1.7.1 to match the version required
|
||||
by Jersey (Alejandro Abdelnur via atm)
|
||||
|
@ -1145,9 +1145,11 @@ public Class<?> getClassByName(String name) throws ClassNotFoundException {
|
||||
* or <code>defaultValue</code>.
|
||||
*/
|
||||
public Class<?>[] getClasses(String name, Class<?> ... defaultValue) {
|
||||
String[] classnames = getTrimmedStrings(name);
|
||||
if (classnames == null)
|
||||
String valueString = getRaw(name);
|
||||
if (null == valueString) {
|
||||
return defaultValue;
|
||||
}
|
||||
String[] classnames = getTrimmedStrings(name);
|
||||
try {
|
||||
Class<?>[] classes = new Class<?>[classnames.length];
|
||||
for(int i = 0; i < classnames.length; i++) {
|
||||
|
@ -837,6 +837,27 @@ public void testGetValByRegex() {
|
||||
assertTrue("Picked out wrong key " + key4, !res.containsKey(key4));
|
||||
}
|
||||
|
||||
public void testGetClassesShouldReturnDefaultValue() throws Exception {
|
||||
Configuration config = new Configuration();
|
||||
Class<?>[] classes =
|
||||
config.getClasses("testClassName", Configuration.class);
|
||||
assertEquals(
|
||||
"Not returning expected number of classes. Number of returned classes ="
|
||||
+ classes.length, 1, classes.length);
|
||||
assertEquals("Not returning the default class Name", Configuration.class,
|
||||
classes[0]);
|
||||
}
|
||||
|
||||
public void testGetClassesShouldReturnEmptyArray()
|
||||
throws Exception {
|
||||
Configuration config = new Configuration();
|
||||
config.set("testClassName", "");
|
||||
Class<?>[] classes = config.getClasses("testClassName", Configuration.class);
|
||||
assertEquals(
|
||||
"Not returning expected number of classes. Number of returned classes ="
|
||||
+ classes.length, 0, classes.length);
|
||||
}
|
||||
|
||||
public static void main(String[] argv) throws Exception {
|
||||
junit.textui.TestRunner.main(new String[]{
|
||||
TestConfiguration.class.getName()
|
||||
|
Loading…
Reference in New Issue
Block a user