-
Notifications
You must be signed in to change notification settings - Fork 910
Update tm builder log messages #3822
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -212,6 +212,17 @@ | |
<version>${commons-codec.verion}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.github.hakky54</groupId> | ||
<artifactId>logcaptor</artifactId> | ||
<version>2.8.0</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.slf4j</groupId> | ||
<artifactId>slf4j-api</artifactId> | ||
<version>2.0.6</version> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is version needed? Can't it inherit from parent pom? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. logcaptor plugin needs 2.x.x version, while parent uses 1.7.30. Upgrading to 2.x.x causes breaking changes There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, I see, then we can't use it unfortunately, because it will break customers. We could potentially making it a test dependency, but this could be error-prone since we could get confused and just remove the test scope in the future. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. got it, removed plugin and dependencies |
||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -120,12 +120,15 @@ public DefaultS3TransferManager(DefaultBuilder tmBuilder) { | |
|
||
if (s3AsyncClient instanceof S3CrtAsyncClient) { | ||
s3ClientType = S3ClientType.CRT_BASED; | ||
} else { | ||
} else if (s3AsyncClient.getClass().getSimpleName().equals("DefaultS3AsyncClient")){ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. getSimpleName is very expensive in spite of the name "simple". Can we use getName? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. updated to getName |
||
s3ClientType = S3ClientType.JAVA_BASED; | ||
log.warn(() -> "The provided S3AsyncClient is not an instance of S3CrtAsyncClient, and thus multipart" | ||
log.warn(() -> "The provided DefaultS3AsyncClient is not an instance of S3CrtAsyncClient, and thus multipart" | ||
+ " upload/download feature is not enabled and resumable file upload is not supported. To benefit " | ||
+ "from maximum throughput," | ||
+ " consider using S3AsyncClient.crtBuilder().build() instead."); | ||
+ "from maximum throughput, consider using S3AsyncClient.crtBuilder().build() instead."); | ||
} else { | ||
s3ClientType = S3ClientType.OTHER; | ||
log.debug(() -> "The provided S3AsyncClient is not an instance of S3CrtAsyncClient, and thus multipart" | ||
+ " upload/download feature may not be enabled and resumable file upload may not be supported."); | ||
} | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,5 +25,6 @@ | |
@SdkInternalApi | ||
public enum S3ClientType { | ||
CRT_BASED, | ||
JAVA_BASED | ||
JAVA_BASED, | ||
OTHER | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://aws.amazon.com/apache2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed | ||
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
|
||
package software.amazon.awssdk.transfer.s3.internal; | ||
|
||
import nl.altindag.log.LogCaptor; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import software.amazon.awssdk.services.s3.S3AsyncClient; | ||
import software.amazon.awssdk.transfer.s3.S3TransferManager; | ||
|
||
public class TransferManagerLoggingTest { | ||
|
||
LogCaptor logCaptor; | ||
|
||
@BeforeEach | ||
void initLogCaptor() { | ||
logCaptor = LogCaptor.forClass(S3TransferManager.class); | ||
} | ||
|
||
@Test | ||
public void transferManager_withCrtClient_shouldNotLogMessages(){ | ||
|
||
S3AsyncClient s3Crt = S3AsyncClient.crtCreate(); | ||
S3TransferManager tm = S3TransferManager.builder().s3Client(s3Crt).build(); | ||
|
||
assertThat(logCaptor.getDebugLogs()).isEmpty(); | ||
assertThat(logCaptor.getWarnLogs()).isEmpty(); | ||
} | ||
|
||
@Test | ||
public void transferManager_withJavaClient_shouldLogWarnMessage(){ | ||
|
||
S3AsyncClient s3Java = S3AsyncClient.create(); | ||
S3TransferManager tm = S3TransferManager.builder().s3Client(s3Java).build(); | ||
|
||
assertThat(logCaptor.getDebugLogs()).isEmpty(); | ||
assertThat(logCaptor.getWarnLogs()).containsExactly("The provided DefaultS3AsyncClient is not an instance of " | ||
+ "S3CrtAsyncClient, and thus multipart upload/download feature is " | ||
+ "not enabled and resumable file upload is not supported. To benefit" | ||
+ " from maximum throughput, consider using " | ||
+ "S3AsyncClient.crtBuilder().build() instead."); | ||
|
||
|
||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's manage versions in one place https://github.com/aws/aws-sdk-java-v2/blob/master/pom.xml#L119
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated