You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by mi...@apache.org on 2019/01/03 10:34:02 UTC
[maven-wagon] branch master updated: [WAGON-544] Work around JSch
issue #122
This is an automated email from the ASF dual-hosted git repository.
michaelo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-wagon.git
The following commit(s) were added to refs/heads/master by this push:
new 69c931b [WAGON-544] Work around JSch issue #122
69c931b is described below
commit 69c931b98c1db02e48e0cc7e95771fba2f99be44
Author: Michael Osipov <mi...@apache.org>
AuthorDate: Wed Jan 2 22:10:31 2019 +0100
[WAGON-544] Work around JSch issue #122
The workaround is merely restoring the previous transfer method on
AbstractJschWagon only.
---
.../java/org/apache/maven/wagon/AbstractWagon.java | 1 -
.../providers/ssh/jsch/AbstractJschWagon.java | 33 ++++++++++++++++++++++
2 files changed, 33 insertions(+), 1 deletion(-)
diff --git a/wagon-provider-api/src/main/java/org/apache/maven/wagon/AbstractWagon.java b/wagon-provider-api/src/main/java/org/apache/maven/wagon/AbstractWagon.java
index 8995559..8827b64 100644
--- a/wagon-provider-api/src/main/java/org/apache/maven/wagon/AbstractWagon.java
+++ b/wagon-provider-api/src/main/java/org/apache/maven/wagon/AbstractWagon.java
@@ -583,7 +583,6 @@ public abstract class AbstractWagon
protected void transfer( Resource resource, InputStream input, OutputStream output, int requestType, long maxSize )
throws IOException
{
-
ByteBuffer buffer = ByteBuffer.allocate( getBufferCapacityForTransfer( resource.getContentLength() ) );
int halfBufferCapacity = buffer.capacity() / 2;
diff --git a/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/jsch/AbstractJschWagon.java b/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/jsch/AbstractJschWagon.java
index c645eda..7e87d2d 100644
--- a/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/jsch/AbstractJschWagon.java
+++ b/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/jsch/AbstractJschWagon.java
@@ -24,7 +24,9 @@ import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
+import java.io.InputStream;
import java.io.InputStreamReader;
+import java.io.OutputStream;
import java.util.List;
import java.util.Properties;
@@ -479,4 +481,35 @@ public abstract class AbstractJschWagon
{
this.strictHostKeyChecking = strictHostKeyChecking;
}
+
+ /** {@inheritDoc} */
+ // This method will be removed as soon as JSch issue #122 is resolved
+ @Override
+ protected void transfer( Resource resource, InputStream input, OutputStream output, int requestType, long maxSize )
+ throws IOException
+ {
+ byte[] buffer = new byte[DEFAULT_BUFFER_SIZE];
+
+ TransferEvent transferEvent = new TransferEvent( this, resource, TransferEvent.TRANSFER_PROGRESS, requestType );
+ transferEvent.setTimestamp( System.currentTimeMillis() );
+
+ long remaining = maxSize;
+ while ( remaining > 0L )
+ {
+ // let's safely cast to int because the min value will be lower than the buffer size.
+ int n = input.read( buffer, 0, (int) Math.min( buffer.length, remaining ) );
+
+ if ( n == -1 )
+ {
+ break;
+ }
+
+ fireTransferProgress( transferEvent, buffer, n );
+
+ output.write( buffer, 0, n );
+
+ remaining -= n;
+ }
+ output.flush();
+ }
}