Skip to content

Commit e0d0682

Browse files
Merge pull request cdapio#16034 from cdapio/CDAP-21202_fix_regex
CDAP-21202 : making validation regex to support dot
2 parents a9fc9f4 + a3b096c commit e0d0682

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

cdap-api/src/main/java/io/cdap/cdap/api/artifact/ArtifactVersion.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public final class ArtifactVersion implements Comparable<ArtifactVersion> {
3737
private static final Pattern PATTERN = Pattern.compile(VERSION_REGEX);
3838
private static final Pattern SUFFIX_PATTERN = Pattern.compile("\\-" + VERSION_REGEX);
3939
// Suffix can contain only alphanumeric characters and hyphen(-)
40-
private static final String SUFFIX_VALIDATION_REGEX = "^[a-zA-Z0-9-]+$";
40+
private static final String SUFFIX_VALIDATION_REGEX = "^[a-zA-Z0-9-.]+$";
4141
private static final Pattern SUFFIX_VALIDATION_PATTERN = Pattern.compile(SUFFIX_VALIDATION_REGEX);
4242

4343
private final String version;
@@ -85,10 +85,10 @@ public ArtifactVersion(String str, boolean matchSuffix) {
8585
}
8686

8787
if (suffix != null) {
88-
Matcher suffix_validation_matcher = SUFFIX_VALIDATION_PATTERN.matcher(suffix);
89-
if (!suffix_validation_matcher.matches()) {
90-
throw new IllegalArgumentException("The suffix of the version is not valid. It should contain only " +
91-
"alphanumeric characters and hyphen(-)");
88+
Matcher suffixValidationMatcher = SUFFIX_VALIDATION_PATTERN.matcher(suffix);
89+
if (!suffixValidationMatcher.matches()) {
90+
throw new IllegalArgumentException("The suffix of the version is not valid. It should contain only "
91+
+ "alphanumeric characters, hyphen(-) and dot(.)");
9292
}
9393
}
9494

cdap-api/src/test/java/io/cdap/cdap/api/artifact/ArtifactVersionTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ public void testArtifactVersionValidationSuccess() {
9595
new ArtifactVersion("1.5.0-SNAPSHOT");
9696
new ArtifactVersion("1.5.0-RC1");
9797
new ArtifactVersion("1.5.0-v2-beta3");
98+
new ArtifactVersion("8-1.0.16-jar-with-driver-and-dependencies");
9899
}
99100

100101
@Test (expected = IllegalArgumentException.class)

0 commit comments

Comments
 (0)