diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/pom.xml b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/pom.xml index 6fb27601e..f653f34e9 100644 --- a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/pom.xml +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/pom.xml @@ -124,7 +124,7 @@ org.apache.maven.wagon wagon-http - test + provided diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/DownloadRemoteIndexTask.java b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/DownloadRemoteIndexTask.java index 24eccecd6..7aeb6fe56 100644 --- a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/DownloadRemoteIndexTask.java +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/DownloadRemoteIndexTask.java @@ -39,6 +39,8 @@ import org.apache.maven.wagon.events.TransferEvent; import org.apache.maven.wagon.events.TransferListener; import org.apache.maven.wagon.proxy.ProxyInfo; import org.apache.maven.wagon.repository.Repository; +import org.apache.maven.wagon.shared.http.HttpConfiguration; +import org.apache.maven.wagon.shared.http.HttpMethodConfiguration; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -47,6 +49,7 @@ import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; +import java.lang.reflect.Method; import java.net.MalformedURLException; import java.net.URL; import java.util.Arrays; @@ -120,6 +123,8 @@ public class DownloadRemoteIndexTask String baseIndexUrl = indexingContext.getIndexUpdateUrl(); final Wagon wagon = wagonFactory.getWagon( new URL( this.remoteRepository.getUrl() ).getProtocol() ); + setupWagonReadTimeout( wagon ); + // TODO transferListener wagon.addTransferListener( new DownloadListener() ); ProxyInfo proxyInfo = null; @@ -244,6 +249,22 @@ public class DownloadRemoteIndexTask } } + private void setupWagonReadTimeout( Wagon wagon ) + { + try + { + HttpConfiguration httpConfiguration = new HttpConfiguration().setAll( + new HttpMethodConfiguration().setReadTimeout( remoteRepository.getRemoteDownloadTimeout() ) ); + Method setHttpConfigurationMethod = + wagon.getClass().getMethod( "setHttpConfiguration", HttpConfiguration.class ); + setHttpConfigurationMethod.invoke( wagon, httpConfiguration ); + } + catch ( Exception e ) + { + log.debug( "unable to set download remote time out for index {}", e.getMessage(), e ); + } + } + public static class DownloadListener implements TransferListener