Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -936,7 +936,7 @@ protected void checkHandlerResult( List<HandlerRequestResponse> handlerRequestRe
{
for ( int i = 0; i < expectedResponseCodes.length; i++ )
{
success &= ( expectedResponseCodes[i] == handlerRequestResponses.get( i ).responseCode );
success &= expectedResponseCodes[i] == handlerRequestResponses.get( i ).responseCode;
Comment thread
slachiewicz marked this conversation as resolved.
}
}

Expand Down Expand Up @@ -2317,7 +2317,8 @@ protected void verifyWagonExceptionMessage( Exception e, int forStatusCode, Stri
// TODO: add test for 410: Gone?
assertTrue( "404 not found response should throw ResourceDoesNotExistException",
e instanceof ResourceDoesNotExistException );
reasonPhrase = StringUtils.isEmpty( forReasonPhrase ) ? " Not Found" : ( " " + forReasonPhrase );
reasonPhrase = ( forReasonPhrase == null || forReasonPhrase.isEmpty() )
? " Not Found" : ( " " + forReasonPhrase );
assertEquals( assertMessageForBadMessage, "resource missing at " + forUrl + ", status: 404"
+ reasonPhrase, e.getMessage() );
break;
Expand All @@ -2328,24 +2329,26 @@ protected void verifyWagonExceptionMessage( Exception e, int forStatusCode, Stri
+ " AuthenticationException is not explicitly declared as thrown from wagon "
+ "methods",
e instanceof AuthorizationException );
reasonPhrase = StringUtils.isEmpty( forReasonPhrase ) ? " Unauthorized" : ( " " + forReasonPhrase );
reasonPhrase = ( forReasonPhrase == null || forReasonPhrase.isEmpty() )
? " Unauthorized" : ( " " + forReasonPhrase );
assertEquals( assertMessageForBadMessage, "authentication failed for " + forUrl + ", status: 401"
+ reasonPhrase, e.getMessage() );
break;

case HttpServletResponse.SC_PROXY_AUTHENTICATION_REQUIRED:
assertTrue( "407 Proxy authentication required should throw AuthorizationException",
e instanceof AuthorizationException );
reasonPhrase = StringUtils.isEmpty( forReasonPhrase ) ? " Proxy Authentication Required"
: ( " " + forReasonPhrase );
reasonPhrase = ( forReasonPhrase == null || forReasonPhrase.isEmpty() )
? " Proxy Authentication Required" : ( " " + forReasonPhrase );
assertEquals( assertMessageForBadMessage, "proxy authentication failed for "
+ forUrl + ", status: 407" + reasonPhrase, e.getMessage() );
break;

case HttpServletResponse.SC_FORBIDDEN:
assertTrue( "403 Forbidden should throw AuthorizationException",
e instanceof AuthorizationException );
reasonPhrase = StringUtils.isEmpty( forReasonPhrase ) ? " Forbidden" : ( " " + forReasonPhrase );
reasonPhrase = ( forReasonPhrase == null || forReasonPhrase.isEmpty() )
? " Forbidden" : ( " " + forReasonPhrase );
assertEquals( assertMessageForBadMessage, "authorization failed for " + forUrl + ", status: 403"
+ reasonPhrase, e.getMessage() );
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import org.apache.maven.wagon.WagonException;
import org.apache.maven.wagon.authorization.AuthorizationException;
import org.apache.maven.wagon.http.HttpWagonTestCase;
import org.codehaus.plexus.util.StringUtils;

import javax.servlet.http.HttpServletResponse;
import java.io.FileNotFoundException;
Expand Down Expand Up @@ -114,7 +113,7 @@ protected void verifyWagonExceptionMessage( Exception e, int forStatusCode, Stri
e instanceof AuthorizationException );

assertEquals( assertMessageForBadMessage, "authorization failed for " + forUrl + ", status: 403"
+ ( StringUtils.isEmpty( forReasonPhrase ) ? " Forbidden" : ( " " + forReasonPhrase ) ),
+ ( (forReasonPhrase == null || forReasonPhrase.isEmpty()) ? " Forbidden" : ( " " + forReasonPhrase ) ),
e.getMessage() );
break;

Expand All @@ -123,7 +122,7 @@ protected void verifyWagonExceptionMessage( Exception e, int forStatusCode, Stri
e instanceof AuthorizationException );

assertEquals( assertMessageForBadMessage, "authentication failed for " + forUrl + ", status: 401"
+ ( StringUtils.isEmpty( forReasonPhrase ) ? " Unauthorized" :
+ ( (forReasonPhrase == null || forReasonPhrase.isEmpty()) ? " Unauthorized" :
( " " + forReasonPhrase ) ),
e.getMessage() );
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@
import org.apache.maven.wagon.proxy.ProxyInfo;
import org.apache.maven.wagon.repository.Repository;
import org.apache.maven.wagon.resource.Resource;
import org.codehaus.plexus.util.StringUtils;

import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
Expand Down Expand Up @@ -448,7 +447,7 @@ private static HttpRequestRetryHandler createRetryHandler()
switch ( RETRY_HANDLER_CLASS )
{
case "default":
if ( StringUtils.isEmpty( RETRY_HANDLER_EXCEPTIONS ) )
if ( RETRY_HANDLER_EXCEPTIONS == null || RETRY_HANDLER_EXCEPTIONS.isEmpty() )
{
return new DefaultHttpRequestRetryHandler(
RETRY_HANDLER_COUNT, RETRY_HANDLER_REQUEST_SENT_ENABLED );
Expand Down Expand Up @@ -606,7 +605,7 @@ public void openConnectionInternal()
String username = authenticationInfo.getUserName();
String password = authenticationInfo.getPassword();

if ( StringUtils.isNotEmpty( username ) && StringUtils.isNotEmpty( password ) )
if ( ( username != null && !username.isEmpty() ) && ( password != null && !password.isEmpty() ) )
{
Credentials creds = new UsernamePasswordCredentials( username, password );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import org.apache.maven.wagon.TransferFailedException;
import org.apache.maven.wagon.authorization.AuthorizationException;
import org.apache.maven.wagon.proxy.ProxyInfo;
import org.codehaus.plexus.util.StringUtils;

/**
* Helper for HTTP related messages.
Expand Down Expand Up @@ -88,7 +87,7 @@ public static String formatTransferDebugMessage( String url, int statusCode, Str
if ( statusCode != UNKNOWN_STATUS_CODE )
{
msg += " -- status code: " + statusCode;
if ( StringUtils.isNotEmpty( reasonPhrase ) )
if ( reasonPhrase != null && !reasonPhrase.isEmpty() )
{
msg += ", reason phrase: " + reasonPhrase;
}
Expand Down Expand Up @@ -195,7 +194,7 @@ private static String formatMessage( String message, String url, int statusCode,
{
msg += ", status: " + statusCode;

if ( StringUtils.isNotEmpty( reasonPhrase ) )
if ( reasonPhrase != null && !reasonPhrase.isEmpty() )
{
msg += " " + reasonPhrase;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,12 +313,12 @@ private ScmRepository getScmRepository( String url )

ScmProviderRepository providerRepository = scmRepository.getProviderRepository();

if ( StringUtils.isNotEmpty( username ) )
if ( username != null && !username.isEmpty() )
{
providerRepository.setUser( username );
}

if ( StringUtils.isNotEmpty( password ) )
if ( password != null && !password.isEmpty() )
{
providerRepository.setPassword( password );
}
Expand All @@ -327,12 +327,12 @@ private ScmRepository getScmRepository( String url )
{
ScmProviderRepositoryWithHost providerRepo = (ScmProviderRepositoryWithHost) providerRepository;

if ( StringUtils.isNotEmpty( privateKey ) )
if ( privateKey != null && !privateKey.isEmpty() )
{
providerRepo.setPrivateKey( privateKey );
}

if ( StringUtils.isNotEmpty( passphrase ) )
if ( passphrase != null && !passphrase.isEmpty() )
{
providerRepo.setPassphrase( passphrase );
}
Expand Down Expand Up @@ -648,13 +648,13 @@ public boolean supportsDirectoryCopy()
private boolean supportsPartialCheckout( ScmProvider scmProvider )
{
String scmType = scmProvider.getScmType();
return ( "svn".equals( scmType ) || "cvs".equals( scmType ) );
return "svn".equals( scmType ) || "cvs".equals( scmType );
}

private boolean isAlwaysRecursive( ScmProvider scmProvider )
{
String scmType = scmProvider.getScmType();
return ( "git".equals( scmType ) || "cvs".equals( scmType ) );
return "git".equals( scmType ) || "cvs".equals( scmType );
}

public void putDirectory( File sourceDirectory, String destinationDirectory )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
import org.apache.maven.wagon.repository.Repository;
import org.apache.maven.wagon.shared.http.AbstractHttpClientWagon;
import org.codehaus.plexus.util.FileUtils;
import org.codehaus.plexus.util.StringUtils;
import org.w3c.dom.Node;

import java.io.File;
Expand Down Expand Up @@ -281,7 +280,7 @@ public List<String> getFileList( String destinationDirectory )
fileName = PathUtils.filename( PathUtils.dirname( URLDecoder.decode( entryUrl ) ) ) + "/";
}

if ( !StringUtils.isEmpty( fileName ) )
if ( !( fileName == null || fileName.isEmpty() ) )
{
dirs.add( fileName );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import org.apache.maven.wagon.authorization.AuthorizationException;
import org.apache.maven.wagon.proxy.ProxyInfo;
import org.codehaus.plexus.util.IOUtil;
import org.codehaus.plexus.util.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -118,7 +117,8 @@ public static void assertWagonExceptionMessage( Exception e, int forStatusCode,
// TODO: add test for 410: Gone?
assertTrue( "404 not found response should throw ResourceDoesNotExistException",
e instanceof ResourceDoesNotExistException );
reasonPhrase = StringUtils.isEmpty( forReasonPhrase ) ? " Not Found" : ( " " + forReasonPhrase );
reasonPhrase = ( forReasonPhrase == null || forReasonPhrase.isEmpty() )
? " Not Found" : ( " " + forReasonPhrase );
assertEquals( assertMessageForBadMessage, "resource missing at " + forUrl + ", status: 404"
+ reasonPhrase, e.getMessage() );
break;
Expand All @@ -129,15 +129,18 @@ public static void assertWagonExceptionMessage( Exception e, int forStatusCode,
+ " AuthenticationException is not explicitly declared as thrown from wagon "
+ "methods",
e instanceof AuthorizationException );
reasonPhrase = StringUtils.isEmpty( forReasonPhrase ) ? " Unauthorized" : ( " " + forReasonPhrase );
reasonPhrase = ( forReasonPhrase == null || forReasonPhrase.isEmpty() )
? " Unauthorized" : ( " " + forReasonPhrase );
assertEquals( assertMessageForBadMessage, "authentication failed for " + forUrl + ", status: 401"
+ reasonPhrase, e.getMessage() );
break;

case HttpServletResponse.SC_PROXY_AUTHENTICATION_REQUIRED:
assertTrue( "407 Proxy authentication required should throw AuthorizationException",
e instanceof AuthorizationException );
reasonPhrase = StringUtils.isEmpty( forReasonPhrase ) ? " Proxy Authentication Required"
reasonPhrase = ( forReasonPhrase == null || forReasonPhrase.isEmpty() )

? " Proxy Authentication Required"
: ( " " + forReasonPhrase );
assertEquals( assertMessageForBadMessage, "proxy authentication failed for "
+ forUrl + ", status: 407" + reasonPhrase, e.getMessage() );
Expand All @@ -146,7 +149,8 @@ public static void assertWagonExceptionMessage( Exception e, int forStatusCode,
case HttpServletResponse.SC_FORBIDDEN:
assertTrue( "403 Forbidden should throw AuthorizationException",
e instanceof AuthorizationException );
reasonPhrase = StringUtils.isEmpty( forReasonPhrase ) ? " Forbidden" : ( " " + forReasonPhrase );
reasonPhrase = ( forReasonPhrase == null || forReasonPhrase.isEmpty() )
? " Forbidden" : ( " " + forReasonPhrase );
assertEquals( assertMessageForBadMessage, "authorization failed for " + forUrl + ", status: 403"
+ reasonPhrase, e.getMessage() );
break;
Expand Down