File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed
main/java/com/vaadin/flow/server/frontend
test/java/com/vaadin/flow/server/frontend Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -338,6 +338,12 @@ private int compareBuildIdentifier(FrontendVersion other) {
338
338
return thisMatcher .group (1 )
339
339
.compareToIgnoreCase (otherMatcher .group (1 ));
340
340
}
341
+ // if one or both are missing numeric value do not parse int
342
+ if (thisMatcher .group (2 ).isEmpty ()
343
+ || otherMatcher .group (2 ).isEmpty ()) {
344
+ return buildIdentifier
345
+ .compareToIgnoreCase (other .buildIdentifier );
346
+ }
341
347
return Integer .parseInt (thisMatcher .group (2 ))
342
348
- Integer .parseInt (otherMatcher .group (2 ));
343
349
}
Original file line number Diff line number Diff line change 3
3
import org .junit .Assert ;
4
4
import org .junit .Test ;
5
5
6
+ import static com .helger .commons .mock .CommonsAssert .assertEquals ;
6
7
import static org .junit .Assert .assertFalse ;
7
8
import static org .junit .Assert .assertTrue ;
8
9
@@ -77,6 +78,18 @@ public void testIsEqualTo() {
77
78
fromString .isEqualTo (fromConstructor ));
78
79
}
79
80
81
+ @ Test // #12041
82
+ public void testSimilarBuildIdentifiers () {
83
+ FrontendVersion version = new FrontendVersion ("1.1.1-SNAPSHOT" );
84
+ FrontendVersion equals = new FrontendVersion ("1.1.1-SNAPSHOT" );
85
+
86
+ assertTrue ("Versions be the same" , version .isEqualTo (equals ));
87
+ assertFalse ("Version should not be older" , version .isOlderThan (equals ));
88
+ assertEquals ("Versions should not have a difference" , 0 ,
89
+ version .compareTo (equals ));
90
+ assertFalse ("Version should not be newer" , version .isNewerThan (equals ));
91
+ }
92
+
80
93
@ Test (expected = NumberFormatException .class )
81
94
public void faultyStringVersion_throwsException () {
82
95
new FrontendVersion ("12.0b.1" );
You can’t perform that action at this time.
0 commit comments