Merge. HDFS-6367. EnumSetParam$Domain#parse fails for parameter containing more than one enum. Contributed by Yi Liu.
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1594151 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
77dc706480
commit
72763dbee9
|
@ -203,6 +203,9 @@ Release 2.5.0 - UNRELEASED
|
||||||
HDFS-5522. Datanode disk error check may be incorrectly skipped.
|
HDFS-5522. Datanode disk error check may be incorrectly skipped.
|
||||||
(Rushabh S Shah via kihwal)
|
(Rushabh S Shah via kihwal)
|
||||||
|
|
||||||
|
HDFS-6367. EnumSetParam$Domain#parse fails for parameter containing more than one enum.
|
||||||
|
(Yi Liu via umamahesh)
|
||||||
|
|
||||||
Release 2.4.1 - UNRELEASED
|
Release 2.4.1 - UNRELEASED
|
||||||
|
|
||||||
INCOMPATIBLE CHANGES
|
INCOMPATIBLE CHANGES
|
||||||
|
|
|
@ -79,8 +79,8 @@ abstract class EnumSetParam<E extends Enum<E>> extends Param<EnumSet<E>, EnumSet
|
||||||
final EnumSet<E> set = EnumSet.noneOf(enumClass);
|
final EnumSet<E> set = EnumSet.noneOf(enumClass);
|
||||||
if (!str.isEmpty()) {
|
if (!str.isEmpty()) {
|
||||||
for(int i, j = 0; j >= 0; ) {
|
for(int i, j = 0; j >= 0; ) {
|
||||||
i = j;
|
i = j > 0 ? j + 1 : 0;
|
||||||
j = str.indexOf(',', i+1);
|
j = str.indexOf(',', i);
|
||||||
final String sub = j >= 0? str.substring(i, j): str.substring(i);
|
final String sub = j >= 0? str.substring(i, j): str.substring(i);
|
||||||
set.add(Enum.valueOf(enumClass, sub.trim().toUpperCase()));
|
set.add(Enum.valueOf(enumClass, sub.trim().toUpperCase()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,12 +21,14 @@ import static org.junit.Assert.assertNotNull;
|
||||||
import static org.junit.Assert.assertNull;
|
import static org.junit.Assert.assertNull;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.EnumSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.apache.hadoop.conf.Configuration;
|
import org.apache.hadoop.conf.Configuration;
|
||||||
import org.apache.hadoop.fs.CommonConfigurationKeysPublic;
|
import org.apache.hadoop.fs.CommonConfigurationKeysPublic;
|
||||||
|
import org.apache.hadoop.fs.Options;
|
||||||
import org.apache.hadoop.fs.Path;
|
import org.apache.hadoop.fs.Path;
|
||||||
import org.apache.hadoop.fs.permission.AclEntry;
|
import org.apache.hadoop.fs.permission.AclEntry;
|
||||||
import org.apache.hadoop.fs.permission.FsPermission;
|
import org.apache.hadoop.fs.permission.FsPermission;
|
||||||
|
@ -346,4 +348,13 @@ public class TestParam {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testRenameOptionSetParam() {
|
||||||
|
final RenameOptionSetParam p = new RenameOptionSetParam(
|
||||||
|
Options.Rename.OVERWRITE, Options.Rename.NONE);
|
||||||
|
final RenameOptionSetParam p1 = new RenameOptionSetParam(
|
||||||
|
p.getValueString());
|
||||||
|
Assert.assertEquals(p1.getValue(), EnumSet.of(
|
||||||
|
Options.Rename.OVERWRITE, Options.Rename.NONE));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue