HADOOP-17518. Update the regex to A-Z (#5669). Contributed by Nishtha Shah.
Signed-off-by: Ayush Saxena <ayushsaxena@apache.org>
This commit is contained in:
parent
0914b3e792
commit
5272ed8670
|
@ -106,13 +106,13 @@ public class Check {
|
||||||
return list;
|
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 + "$");
|
private static final Pattern IDENTIFIER_PATTERN = Pattern.compile("^" + IDENTIFIER_PATTERN_STR + "$");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Verifies a value is a valid identifier,
|
* Verifies a value is a valid identifier,
|
||||||
* <code>[a-zA-z_][a-zA-Z0-9_\-]*</code>, up to a maximum length.
|
* <code>[a-zA-Z_][a-zA-Z0-9_\-]*</code>, up to a maximum length.
|
||||||
*
|
*
|
||||||
* @param value string to check if it is a valid identifier.
|
* @param value string to check if it is a valid identifier.
|
||||||
* @param maxLen maximun length.
|
* @param maxLen maximun length.
|
||||||
|
|
|
@ -116,6 +116,16 @@ public class TestCheck extends HTestCase {
|
||||||
Check.validIdentifier("1", 1, "");
|
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
|
@Test
|
||||||
public void checkGTZeroGreater() {
|
public void checkGTZeroGreater() {
|
||||||
assertEquals(Check.gt0(120, "test"), 120);
|
assertEquals(Check.gt0(120, "test"), 120);
|
||||||
|
|
|
@ -36,7 +36,7 @@ import org.apache.hadoop.yarn.factory.providers.RecordFactoryProvider;
|
||||||
public final class ResourceTypesTestHelper {
|
public final class ResourceTypesTestHelper {
|
||||||
|
|
||||||
private static final Pattern RESOURCE_VALUE_AND_UNIT_PATTERN =
|
private static final Pattern RESOURCE_VALUE_AND_UNIT_PATTERN =
|
||||||
Pattern.compile("(\\d+)([A-za-z]*)");
|
Pattern.compile("(\\d+)([A-Za-z]*)");
|
||||||
|
|
||||||
private ResourceTypesTestHelper() {}
|
private ResourceTypesTestHelper() {}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue