This is an automated email from the ASF dual-hosted git repository. michaelo pushed a commit to branch WAGON-518 in repository https://gitbox.apache.org/repos/asf/maven-wagon.git
commit 9590d0a1a19aec217d7f1e2e56429893868209bc Author: Michael Osipov <[email protected]> AuthorDate: Sun Apr 22 12:40:20 2018 +0200 [WAGON-518] AbstractHttpClientWagon#putFromStream() reads entire content to memory --- .../wagon/shared/http/AbstractHttpClientWagon.java | 31 +++++++--------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/wagon-providers/wagon-http-shared/src/main/java/org/apache/maven/wagon/shared/http/AbstractHttpClientWagon.java b/wagon-providers/wagon-http-shared/src/main/java/org/apache/maven/wagon/shared/http/AbstractHttpClientWagon.java index db34732..6c47557 100755 --- a/wagon-providers/wagon-http-shared/src/main/java/org/apache/maven/wagon/shared/http/AbstractHttpClientWagon.java +++ b/wagon-providers/wagon-http-shared/src/main/java/org/apache/maven/wagon/shared/http/AbstractHttpClientWagon.java @@ -71,19 +71,16 @@ import org.apache.maven.wagon.events.TransferEvent; 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.IOUtil; import org.codehaus.plexus.util.StringUtils; import javax.net.ssl.HttpsURLConnection; import javax.net.ssl.SSLContext; -import java.io.ByteArrayInputStream; import java.io.Closeable; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; -import java.nio.ByteBuffer; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; @@ -109,12 +106,14 @@ public abstract class AbstractHttpClientWagon private final Wagon wagon; - private ByteBuffer byteBuffer; + private InputStream stream; private File source; private long length = -1; + private boolean repeatable; + private RequestEntityImplementation( final InputStream stream, final Resource resource, final Wagon wagon, final File source ) throws TransferFailedException @@ -122,24 +121,12 @@ public abstract class AbstractHttpClientWagon if ( source != null ) { this.source = source; + this.repeatable = true; } else { - try - { - byte[] bytes = IOUtil.toByteArray( stream ); - byteBuffer = ByteBuffer.allocate( bytes.length ); - byteBuffer.put( bytes ); - stream.close(); - } - catch ( IOException e ) - { - throw new TransferFailedException( e.getMessage(), e ); - } - finally - { - IOUtil.close( stream ); - } + this.stream = stream; + this.repeatable = false; } this.resource = resource; this.length = resource == null ? -1 : resource.getContentLength(); @@ -159,12 +146,12 @@ public abstract class AbstractHttpClientWagon { return new FileInputStream( this.source ); } - return new ByteArrayInputStream( this.byteBuffer.array() ); + return stream; } public boolean isRepeatable() { - return true; + return repeatable; } public void writeTo( final OutputStream outputStream ) @@ -179,7 +166,7 @@ public abstract class AbstractHttpClientWagon transferEvent.setTimestamp( System.currentTimeMillis() ); InputStream instream = ( this.source != null ) ? new FileInputStream( this.source ) - : new ByteArrayInputStream( this.byteBuffer.array() ); + : stream; try { byte[] buffer = new byte[BUFFER_SIZE]; -- To stop receiving notification emails like this one, please contact [email protected].
