michael-o commented on a change in pull request #242: Speed up project discovery
URL: https://github.com/apache/maven/pull/242#discussion_r274282725
 
 

 ##########
 File path: 
maven-artifact/src/main/java/org/apache/maven/artifact/versioning/DefaultArtifactVersion.java
 ##########
 @@ -163,30 +158,42 @@ public final void parseVersion( String version )
             boolean fallback = false;
 
             StringTokenizer tok = new StringTokenizer( part1, "." );
-            try
+            if ( tok.hasMoreTokens() )
             {
                 majorVersion = getNextIntegerToken( tok );
-                if ( tok.hasMoreTokens() )
-                {
-                    minorVersion = getNextIntegerToken( tok );
-                }
-                if ( tok.hasMoreTokens() )
+                if ( majorVersion == null )
                 {
-                    incrementalVersion = getNextIntegerToken( tok );
+                    fallback = true;
                 }
-                if ( tok.hasMoreTokens() )
+            }
+            else
+            {
+                fallback = true;
+            }
+            if ( tok.hasMoreTokens() )
+            {
+                minorVersion = getNextIntegerToken( tok );
+                if ( minorVersion == null )
                 {
-                    qualifier = tok.nextToken();
-                    fallback = Pattern.compile( "\\d+" ).matcher( qualifier 
).matches();
+                    fallback = true;
                 }
-
-                // string tokenizer won't detect these and ignores them
-                if ( part1.contains( ".." ) || part1.startsWith( "." ) || 
part1.endsWith( "." ) )
+            }
+            if ( tok.hasMoreTokens() )
+            {
+                incrementalVersion = getNextIntegerToken( tok );
+                if ( incrementalVersion == null )
                 {
                     fallback = true;
                 }
             }
-            catch ( NumberFormatException e )
+            if ( tok.hasMoreTokens() )
+            {
+                qualifier = tok.nextToken();
+                fallback = Pattern.compile( "\\d+" ).matcher( qualifier 
).matches();
 
 Review comment:
   Why not, if you know that this works better that with regex.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to