continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r685328 - in /continuum/trunk/continuum-commons/src: main/java/org/apache/maven/continuum/utils/ContinuumUrlValidator.java test/java/org/apache/maven/continuum/utils/ContinuumUrlValidatorTest.java
Date Tue, 12 Aug 2008 21:38:35 GMT
Author: olamy
Date: Tue Aug 12 14:38:35 2008
New Revision: 685328

URL: http://svn.apache.org/viewvc?rev=685328&view=rev
Log:
fix possible NPE

Modified:
    continuum/trunk/continuum-commons/src/main/java/org/apache/maven/continuum/utils/ContinuumUrlValidator.java
    continuum/trunk/continuum-commons/src/test/java/org/apache/maven/continuum/utils/ContinuumUrlValidatorTest.java

Modified: continuum/trunk/continuum-commons/src/main/java/org/apache/maven/continuum/utils/ContinuumUrlValidator.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-commons/src/main/java/org/apache/maven/continuum/utils/ContinuumUrlValidator.java?rev=685328&r1=685327&r2=685328&view=diff
==============================================================================
--- continuum/trunk/continuum-commons/src/main/java/org/apache/maven/continuum/utils/ContinuumUrlValidator.java
(original)
+++ continuum/trunk/continuum-commons/src/main/java/org/apache/maven/continuum/utils/ContinuumUrlValidator.java
Tue Aug 12 14:38:35 2008
@@ -101,8 +101,6 @@
 
     private static final String AUTHORITY_PATTERN = "/^([" + AUTHORITY_CHARS + "]*)(:\\d*)?(.*)?/";
 
-    //                                                                            1     
                    2  3       4
-
     private static final int PARSE_AUTHORITY_HOST_IP = 1;
 
     private static final int PARSE_AUTHORITY_PORT = 2;
@@ -252,24 +250,26 @@
         {
             String authority = matchUrlPat.group( PARSE_URL_AUTHORITY );
 
-            if ( authority.indexOf( "@" ) != -1 )
+            if ( authority != null )
             {
-                String userPassword = authority.substring( 0, authority.indexOf( "@" ) );
+                if ( authority.indexOf( "@" ) != -1 )
+                {
+                    String userPassword = authority.substring( 0, authority.indexOf( "@"
) );
 
-                authority = authority.substring( authority.indexOf( "@" ) + 1 );
+                    authority = authority.substring( authority.indexOf( "@" ) + 1 );
 
-                if ( userPassword.indexOf( ":" ) == -1 ||
-                     userPassword.indexOf( ":" ) == 0 ||
-                     userPassword.indexOf( ":" ) == userPassword.length() - 1 )
+                    if ( userPassword.indexOf( ":" ) == -1 || userPassword.indexOf( ":" )
== 0
+                        || userPassword.indexOf( ":" ) == userPassword.length() - 1 )
+                    {
+                        return false;
+                    }
+                }
+                if ( !isValidAuthority( authority ) )
                 {
                     return false;
-                }
+                }                
             }
 
-            if ( !isValidAuthority( authority ) )
-            {
-                return false;
-            }
 
             if ( !isValidQuery( matchUrlPat.group( PARSE_URL_QUERY ) ) )
             {

Modified: continuum/trunk/continuum-commons/src/test/java/org/apache/maven/continuum/utils/ContinuumUrlValidatorTest.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-commons/src/test/java/org/apache/maven/continuum/utils/ContinuumUrlValidatorTest.java?rev=685328&r1=685327&r2=685328&view=diff
==============================================================================
--- continuum/trunk/continuum-commons/src/test/java/org/apache/maven/continuum/utils/ContinuumUrlValidatorTest.java
(original)
+++ continuum/trunk/continuum-commons/src/test/java/org/apache/maven/continuum/utils/ContinuumUrlValidatorTest.java
Tue Aug 12 14:38:35 2008
@@ -115,4 +115,5 @@
         assertTrue( new ContinuumUrlValidator()
             .validate( "https://fisheye6.atlassian.com/browse/~raw,r=680040/continuum/trunk/pom.xml"
) );
     }
+   
 }



Mime
View raw message