diff --git a/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/lib/util/Check.java b/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/lib/util/Check.java
index 31666e83e27..968773d687a 100644
--- a/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/lib/util/Check.java
+++ b/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/lib/util/Check.java
@@ -106,13 +106,13 @@ public class Check {
return list;
}
- private static final String IDENTIFIER_PATTERN_STR = "[a-zA-z_][a-zA-Z0-9_\\-]*";
+ private static final String IDENTIFIER_PATTERN_STR = "[a-zA-Z_][a-zA-Z0-9_\\-]*";
private static final Pattern IDENTIFIER_PATTERN = Pattern.compile("^" + IDENTIFIER_PATTERN_STR + "$");
/**
* Verifies a value is a valid identifier,
- * [a-zA-z_][a-zA-Z0-9_\-]*
, up to a maximum length.
+ * [a-zA-Z_][a-zA-Z0-9_\-]*
, up to a maximum length.
*
* @param value string to check if it is a valid identifier.
* @param maxLen maximun length.
diff --git a/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/lib/util/TestCheck.java b/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/lib/util/TestCheck.java
index 877dcd46bc7..a6ff4788f69 100644
--- a/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/lib/util/TestCheck.java
+++ b/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/lib/util/TestCheck.java
@@ -116,6 +116,16 @@ public class TestCheck extends HTestCase {
Check.validIdentifier("1", 1, "");
}
+ @Test(expected = IllegalArgumentException.class)
+ public void validIdentifierInvalid4() throws Exception {
+ Check.validIdentifier("`a", 2, "");
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void validIdentifierInvalid5() throws Exception {
+ Check.validIdentifier("[a", 2, "");
+ }
+
@Test
public void checkGTZeroGreater() {
assertEquals(Check.gt0(120, "test"), 120);
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/resourcetypes/ResourceTypesTestHelper.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/resourcetypes/ResourceTypesTestHelper.java
index 95b02c49660..a1e2205aa7e 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/resourcetypes/ResourceTypesTestHelper.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/resourcetypes/ResourceTypesTestHelper.java
@@ -36,7 +36,7 @@ import org.apache.hadoop.yarn.factory.providers.RecordFactoryProvider;
public final class ResourceTypesTestHelper {
private static final Pattern RESOURCE_VALUE_AND_UNIT_PATTERN =
- Pattern.compile("(\\d+)([A-za-z]*)");
+ Pattern.compile("(\\d+)([A-Za-z]*)");
private ResourceTypesTestHelper() {}