oehme commented on a change in pull request #242: Speed up project discovery
URL: https://github.com/apache/maven/pull/242#discussion_r274286535
##########
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:
I generally only change things if I can measure they are a problem.
Otherwise one can quickly get into a situation where things get worse or the
code gets less readable without a benefit.
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services