HADOOP-7851. Configuration.getClasses() never returns the default value. (amarrk)
(cherry picked from commit 82d57ee7fee82919b42066af38063a27d0998806)
This commit is contained in:
parent
2b067895a1
commit
61ba70c978
@ -151,6 +151,9 @@ Release 2.7.4 - UNRELEASED
|
||||
HADOOP-14434. Use MoveFileEx to allow renaming a file when the destination
|
||||
exists. (Lukas Majercak via cdouglas)
|
||||
|
||||
HADOOP-7851. Configuration.getClasses() never returns the default value.
|
||||
(Uma Maheswara Rao G via amarrk)
|
||||
|
||||
Release 2.7.3 - 2016-08-25
|
||||
|
||||
INCOMPATIBLE CHANGES
|
||||
@ -5382,9 +5385,6 @@ Release 0.23.1 - 2012-02-17
|
||||
|
||||
HADOOP-7841. Run tests with non-secure random. (tlipcon)
|
||||
|
||||
HADOOP-7851. Configuration.getClasses() never returns the default value.
|
||||
(Uma Maheswara Rao G via amarrk)
|
||||
|
||||
HADOOP-7787. Make source tarball use conventional name.
|
||||
(Bruno Mahé via tomwhite)
|
||||
|
||||
|
@ -2161,9 +2161,11 @@ public Class<?> getClassByNameOrNull(String name) {
|
||||
* 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++) {
|
||||
|
@ -1355,6 +1355,27 @@ public void run() {
|
||||
// it's expected behaviour.
|
||||
}
|
||||
|
||||
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…
x
Reference in New Issue
Block a user