You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by hb...@apache.org on 2019/03/17 10:02:34 UTC

[maven] 02/02: [MNG-6572] Changed StringUtils.stripStart by a regex as requested.

This is an automated email from the ASF dual-hosted git repository.

hboutemy pushed a commit to branch MNG-6572
in repository https://gitbox.apache.org/repos/asf/maven.git

commit de1ea3de9dcb9510b1981a40b91465c3af624918
Author: Gabriel Belingueres <be...@gmail.com>
AuthorDate: Sun Feb 24 16:28:49 2019 -0300

    [MNG-6572] Changed StringUtils.stripStart by a regex as requested.
---
 .../org/apache/maven/artifact/versioning/ComparableVersion.java    | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/maven-artifact/src/main/java/org/apache/maven/artifact/versioning/ComparableVersion.java b/maven-artifact/src/main/java/org/apache/maven/artifact/versioning/ComparableVersion.java
index c0ad57d..960c5dc 100644
--- a/maven-artifact/src/main/java/org/apache/maven/artifact/versioning/ComparableVersion.java
+++ b/maven-artifact/src/main/java/org/apache/maven/artifact/versioning/ComparableVersion.java
@@ -28,8 +28,7 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Locale;
 import java.util.Properties;
-
-import org.apache.commons.lang3.StringUtils;
+import java.util.regex.Pattern;
 
 /**
  * <p>
@@ -65,6 +64,8 @@ import org.apache.commons.lang3.StringUtils;
 public class ComparableVersion
     implements Comparable<ComparableVersion>
 {
+    private static final Pattern STRIP_LEADING_ZEROES_REGEX = Pattern.compile( "^0+" );
+
     private static final int MAX_INTITEM_LENGTH = 9;
 
     private static final int MAX_LONGITEM_LENGTH = 18;
@@ -609,7 +610,7 @@ public class ComparableVersion
 
     private static String stripLeadingZeroes( String buf )
     {
-        String strippedBuf = StringUtils.stripStart( buf, "0" );
+        String strippedBuf = STRIP_LEADING_ZEROES_REGEX.matcher( buf ).replaceFirst( "" );
         if ( strippedBuf.isEmpty() )
         {
             return "0";