Skip to content
Commits on Source (2)
......@@ -29,7 +29,7 @@ under the License.
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon</artifactId>
<version>3.3.1</version>
<version>3.3.3</version>
<packaging>pom</packaging>
<name>Apache Maven Wagon</name>
......@@ -200,7 +200,7 @@ under the License.
<connection>scm:git:https://gitbox.apache.org/repos/asf/maven-wagon.git</connection>
<developerConnection>scm:git:https://gitbox.apache.org/repos/asf/maven-wagon.git</developerConnection>
<url>https://github.com/apache/maven-wagon/tree/${project.scm.tag}</url>
<tag>wagon-3.3.1</tag>
<tag>wagon-3.3.3</tag>
</scm>
<issueManagement>
......@@ -256,7 +256,7 @@ under the License.
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-interactivity-api</artifactId>
<version>1.0-alpha-6</version>
<version>1.0</version>
<exclusions>
<exclusion>
<groupId>plexus</groupId>
......@@ -280,7 +280,7 @@ under the License.
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
<version>3.1.0</version>
<version>3.2.0</version>
</dependency>
<!-- for slf4j -->
......@@ -428,6 +428,7 @@ under the License.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>3.0.0-M2</version>
<executions>
<execution>
<goals>
......
......@@ -23,7 +23,7 @@ under the License.
<parent>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon</artifactId>
<version>3.3.1</version>
<version>3.3.3</version>
<relativePath>../pom.xml</relativePath>
</parent>
......
......@@ -643,10 +643,14 @@ protected int getBufferCapacityForTransfer( long numberOfBytes )
return DEFAULT_BUFFER_SIZE;
}
final int numberOfBufferSegments = (int)
numberOfBytes / ( BUFFER_SEGMENT_SIZE * MINIMUM_AMOUNT_OF_TRANSFER_CHUNKS );
final int potentialBufferSize = numberOfBufferSegments * BUFFER_SEGMENT_SIZE;
return min( MAXIMUM_BUFFER_SIZE, max( DEFAULT_BUFFER_SIZE, potentialBufferSize ) );
final long numberOfBufferSegments = numberOfBytes
/ ( BUFFER_SEGMENT_SIZE * MINIMUM_AMOUNT_OF_TRANSFER_CHUNKS );
final long potentialBufferSize = numberOfBufferSegments * BUFFER_SEGMENT_SIZE;
if ( potentialBufferSize > Integer.MAX_VALUE )
{
return MAXIMUM_BUFFER_SIZE;
}
return min( MAXIMUM_BUFFER_SIZE, max( DEFAULT_BUFFER_SIZE, (int) potentialBufferSize ) );
}
// ----------------------------------------------------------------------
......
......@@ -157,7 +157,7 @@ static String authorization( final String url )
return "localhost";
}
final String protocol = PathUtils.protocol( url );
String protocol = PathUtils.protocol( url );
if ( protocol == null || protocol.equalsIgnoreCase( "file" ) )
{
......@@ -171,6 +171,13 @@ static String authorization( final String url )
host = host.substring( host.indexOf( ":", 4 ) + 1 ).trim();
}
protocol = PathUtils.protocol( host );
if ( protocol.equalsIgnoreCase( "file" ) )
{
return "localhost";
}
// skip over protocol
host = host.substring( host.indexOf( ":" ) + 1 ).trim();
if ( host.startsWith( "//" ) )
......@@ -292,7 +299,7 @@ public static int port( String url )
/**
* Derive the path portion of the given URL.
*
*
* @param url the repository URL
* @return the basedir of the repository
* @todo need to URL decode for spaces?
......@@ -408,7 +415,7 @@ else if ( index >= 0 )
/**
* Decodes the specified (portion of a) URL. <strong>Note:</strong> This decoder assumes that ISO-8859-1 is used to
* convert URL-encoded octets to characters.
*
*
* @param url The URL to decode, may be <code>null</code>.
* @return The decoded URL or <code>null</code> if the input was <code>null</code>.
*/
......
......@@ -117,6 +117,23 @@ protected void setUp()
}
public void testCalculationOfTransferBufferSize() {
// 1 KiB -> Default buffer size (4 KiB)
assertEquals( 4096, wagon.getBufferCapacityForTransfer(1024L ) );
// 1 MiB -> Twice the default buffer size (8 KiB)
assertEquals( 4096 * 2, wagon.getBufferCapacityForTransfer(1024L * 1024 ) );
// 100 MiB -> Maximum buffer size (512 KiB)
assertEquals( 4096 * 128, wagon.getBufferCapacityForTransfer(1024L * 1024 * 100 ) );
// 1 GiB -> Maximum buffer size (512 KiB)
assertEquals( 4096 * 128, wagon.getBufferCapacityForTransfer(1024L * 1024 * 1024 ) );
// 100 GiB -> Maximum buffer size (512 KiB)
assertEquals( 4096 * 128, wagon.getBufferCapacityForTransfer(1024L * 1024 * 1024 * 100 ) );
}
public void testSessionListenerRegistration()
{
assertTrue( wagon.hasSessionListener( sessionListener ) );
......
......@@ -23,7 +23,7 @@ under the License.
<parent>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon</artifactId>
<version>3.3.1</version>
<version>3.3.3</version>
<relativePath>../pom.xml</relativePath>
</parent>
......
......@@ -42,6 +42,7 @@
import java.io.File;
import java.io.IOException;
import java.net.ServerSocket;
import java.nio.charset.StandardCharsets;
import java.security.NoSuchAlgorithmException;
import java.text.SimpleDateFormat;
......@@ -135,12 +136,22 @@ protected abstract String getTestRepositoryUrl()
*/
protected abstract String getProtocol();
/**
* The number of the port which should get used to start the test server
*
* @return the port number for the test server
*/
protected abstract int getTestRepositoryPort();
public static ServerSocket newServerSocket( int... ports )
{
for ( int port : ports )
{
try
{
return new ServerSocket( port );
}
catch ( IOException ex )
{
continue;
}
}
throw new RuntimeException( "no port available" );
}
// ----------------------------------------------------------------------
// 1. Create a local file repository which mimic a users local file
......@@ -170,9 +181,10 @@ protected void setupRepositories()
// Create a test local repository.
// ----------------------------------------------------------------------
localRepositoryPath = FileTestUtils.createDir( "local-repository" ).getPath();
File file = FileTestUtils.createDir( "local-repository" );
localRepositoryPath = file.getPath();
localRepository = createFileRepository( "file://" + localRepositoryPath );
localRepository = createFileRepository( file.toPath().toUri().toASCIIString() );
message( "Local repository: " + localRepository );
......
......@@ -127,7 +127,6 @@ protected void setupWagonTestingFixtures()
testRepository.setUrl( getTestRepositoryUrl() );
}
@Override
protected final int getTestRepositoryPort()
{
if ( server == null )
......
......@@ -23,7 +23,7 @@ under the License.
<parent>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon</artifactId>
<version>3.3.1</version>
<version>3.3.3</version>
<relativePath>../pom.xml</relativePath>
</parent>
......@@ -50,12 +50,12 @@ under the License.
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.6</version>
<version>4.5.9</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<version>4.4.10</version>
<version>4.4.11</version>
</dependency>
<dependency>
<groupId>org.apache.sshd</groupId>
......
......@@ -23,7 +23,7 @@ under the License.
<parent>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-providers</artifactId>
<version>3.3.1</version>
<version>3.3.3</version>
<relativePath>../pom.xml</relativePath>
</parent>
......
......@@ -47,13 +47,7 @@ protected String getTestRepositoryUrl()
{
File file = FileTestUtils.createUniqueDir( getName() + ".file-repository." );
return "file://" + file.getPath();
}
@Override
protected int getTestRepositoryPort() {
// file transfer dont needs a port
return 0;
return file.toPath().toUri().toASCIIString();
}
/**
......@@ -81,7 +75,7 @@ protected long getExpectedLastModifiedOnGet( Repository repository, Resource res
public void testResourceExists()
throws Exception
{
String url = "file://" + getBasedir();
String url = new File( getBasedir() ).toPath().toUri().toASCIIString();
Wagon wagon = new FileWagon();
Repository repository = new Repository( "someID", url );
......
......@@ -23,7 +23,7 @@ under the License.
<parent>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-providers</artifactId>
<version>3.3.1</version>
<version>3.3.3</version>
<relativePath>../pom.xml</relativePath>
</parent>
......@@ -37,13 +37,13 @@ under the License.
<dependency>
<groupId>commons-net</groupId>
<artifactId>commons-net</artifactId>
<version>3.5</version>
<version>3.6</version>
</dependency>
<dependency>
<groupId>org.apache.ftpserver</groupId>
<artifactId>ftpserver-core</artifactId>
<version>1.0.6</version>
<version>1.1.1</version>
<scope>test</scope>
</dependency>
<dependency>
......
......@@ -19,6 +19,12 @@
* under the License.
*/
import java.io.File;
import java.io.IOException;
import java.net.ServerSocket;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.io.FileUtils;
import org.apache.ftpserver.FtpServer;
import org.apache.ftpserver.FtpServerFactory;
......@@ -36,11 +42,6 @@
import org.apache.maven.wagon.repository.Repository;
import org.apache.maven.wagon.resource.Resource;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
/**
* @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
*
......@@ -49,15 +50,31 @@ public class FtpWagonTest
extends StreamingWagonTestCase
{
static private FtpServer server;
// private static final int testRepositoryPort = 10023 + new Random().nextInt( 16 );
private static int testRepositoryPort;
protected String getProtocol()
{
return "ftp";
}
static
{
// claim number, release it again so it can be reclaimed by ftp server
try (ServerSocket socket = newServerSocket( 10023, 10024, 10025, 10026 ))
{
testRepositoryPort = socket.getLocalPort();
}
catch ( IOException e )
{
e.printStackTrace();
}
}
@Override
protected int getTestRepositoryPort() {
return 10023;
return testRepositoryPort;
}
protected void setupWagonTestingFixtures()
......@@ -77,7 +94,7 @@ protected void setupWagonTestingFixtures()
// set the port of the listener
factory.setPort(getTestRepositoryPort());
// replace the default listener
serverFactory.addListener("default", factory.createListener());
......
......@@ -23,7 +23,7 @@ under the License.
<parent>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-providers</artifactId>
<version>3.3.1</version>
<version>3.3.3</version>
<relativePath>../pom.xml</relativePath>
</parent>
......
......@@ -23,7 +23,7 @@ under the License.
<parent>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-providers</artifactId>
<version>3.3.1</version>
<version>3.3.3</version>
<relativePath>../pom.xml</relativePath>
</parent>
......@@ -37,7 +37,7 @@ under the License.
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.11.2</version>
<version>1.12.1</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
......
......@@ -272,6 +272,16 @@ public boolean isStreaming()
private static final int MAX_CONN_TOTAL =
Integer.parseInt( System.getProperty( "maven.wagon.httpconnectionManager.maxTotal", "40" ) );
/**
* Time to live in seconds for an HTTP connection. After that time, the connection will be dropped.
* Intermediates tend to drop connections after some idle period. Set to -1 to maintain connections
* indefinitely. This value defaults to 300 seconds.
*
* @since 3.2
*/
private static final long CONN_TTL =
Long.getLong( "maven.wagon.httpconnectionManager.ttlSeconds", 300L );
/**
* Internal connection manager
*/
......@@ -306,16 +316,6 @@ public boolean isStreaming()
private static final int MAX_BACKOFF_WAIT_SECONDS =
Integer.parseInt( System.getProperty( "maven.wagon.httpconnectionManager.maxBackoffSeconds", "180" ) );
/**
* Time to live in seconds for an HTTP connection. After that time, the connection will be dropped.
* Intermediates tend to drop connections after some idle period. Set to -1 to maintain connections
* indefinitely. This value defaults to 300 seconds.
*
* @since 3.2
*/
private static final long CONN_TTL =
Long.getLong( "maven.wagon.httpconnectionManager.ttlSeconds", 300L );
protected int backoff( int wait, String url )
throws InterruptedException, TransferFailedException
{
......
......@@ -23,7 +23,7 @@ under the License.
<parent>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-providers</artifactId>
<version>3.3.1</version>
<version>3.3.3</version>
<relativePath>../pom.xml</relativePath>
</parent>
......
package org.apache.maven.wagon.providers.http;
import java.io.IOException;
import java.net.ServerSocket;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
......@@ -20,6 +23,7 @@
*/
import org.apache.maven.wagon.Wagon;
import org.apache.maven.wagon.WagonTestCase;
import org.codehaus.plexus.PlexusTestCase;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.handler.ResourceHandler;
......@@ -31,7 +35,7 @@
public abstract class HttpWagonHttpServerTestCase
extends PlexusTestCase
{
protected final int httpServerPort = 10008;
protected static int httpServerPort;
private Server server;
......@@ -39,6 +43,19 @@ public abstract class HttpWagonHttpServerTestCase
protected ServletContextHandler context;
static
{
// claim number, release it again so it can be reclaimed by ftp server
try ( ServerSocket socket = WagonTestCase.newServerSocket( 10008, 10009, 10010, 10011 ) )
{
httpServerPort = socket.getLocalPort();
}
catch ( IOException e )
{
e.printStackTrace();
}
}
protected void setUp()
throws Exception
{
......
......@@ -19,7 +19,6 @@
* under the License.
*/
import junit.framework.Assert;
import org.apache.maven.wagon.Wagon;
import org.apache.maven.wagon.observers.Debug;
import org.apache.maven.wagon.repository.Repository;
......@@ -106,7 +105,7 @@ protected void doGet( HttpServletRequest req, HttpServletResponse resp )
LOGGER.info( "Fetching 'hugefile.txt' with content length" );
wagon.get( "hugefile.txt", dest );
Assert.assertTrue( dest.length() >= HUGE_FILE_SIZE );
assertTrue( dest.length() >= HUGE_FILE_SIZE );
LOGGER.info( "The file was successfully fetched" );
wagon.disconnect();
......@@ -163,7 +162,7 @@ protected void doGet( HttpServletRequest req, HttpServletResponse resp )
LOGGER.info( "Fetching 'hugefile.txt' in chunks" );
wagon.get( "hugefile.txt", dest );
Assert.assertTrue( dest.length() >= HUGE_FILE_SIZE );
assertTrue( dest.length() >= HUGE_FILE_SIZE );
LOGGER.info( "The file was successfully fetched" );
wagon.disconnect();
......
......@@ -23,7 +23,7 @@ under the License.
<parent>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-providers</artifactId>
<version>3.3.1</version>
<version>3.3.3</version>
<relativePath>../pom.xml</relativePath>
</parent>
......@@ -65,6 +65,12 @@ under the License.
<version>${mavenScmVersion}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.scm</groupId>
<artifactId>maven-scm-provider-gittest</artifactId>
<version>${mavenScmVersion}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.scm</groupId>
<artifactId>maven-scm-provider-svnexe</artifactId>
......