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/05/10 20:21:11 UTC
[maven-wagon] 01/02: WAGON-557 Wrap around in
AbstractWagon.getBufferCapacityForTransfer prevents optimal buffer size
selection for large artifacts
This is an automated email from the ASF dual-hosted git repository.
michaelo pushed a commit to branch WAGON-557
in repository https://gitbox.apache.org/repos/asf/maven-wagon.git
commit 947fa6be3c7968f548cebb8a00995eda2a7f90c9
Author: olaf.otto <ol...@unic.com>
AuthorDate: Thu May 9 16:17:25 2019 +0200
WAGON-557 Wrap around in AbstractWagon.getBufferCapacityForTransfer prevents optimal buffer size selection for large artifacts
Made the handling of overly large potential buffer sizes more explicit
---
.../src/main/java/org/apache/maven/wagon/AbstractWagon.java | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
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 8827b64..95ad47e 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
@@ -643,10 +643,14 @@ public abstract class AbstractWagon
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 ) );
}
// ----------------------------------------------------------------------