Skip to content

Commit 788c4cb

Browse files
quantranhong1999chibenwa
authored andcommitted
JAMES-4137 Upgrade S3 SDK to 2.30.x onwards
1 parent 6b107f4 commit 788c4cb

File tree

4 files changed

+34
-5
lines changed

4 files changed

+34
-5
lines changed

docs/modules/servers/partials/configure/jvm.adoc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,18 @@ To enable blob hierarchy compatible with MinIO add in `jvm.properties`:
9090
james.s3.minio.compatibility.mode=true
9191
----
9292

93+
== Disable S3 checksum backward compatibility
94+
95+
By default, James enables backward compatibility for S3 SDK checksum mechanisms to support S3 compatible object storages which rely on MD5 checksum. This can be disabled for native AWS S3 that does not need to rely on the MD5 checksum.
96+
97+
Optional. Boolean. Defaults to true.
98+
99+
Ex in `jvm.properties`
100+
----
101+
james.s3.sdk.checksum.backward.compatibility=false
102+
----
103+
To disable S3 checksum backward compatibility.
104+
93105
== JMAP Quota draft compatibility
94106

95107
Some JMAP clients depend on the JMAP Quota draft specifications. The property `james.jmap.quota.draft.compatibility` allows

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,7 @@
644644
<junit.platform.version>1.10.2</junit.platform.version>
645645
<junit.vintage.version>5.10.2</junit.vintage.version>
646646
<concurrent.version>1.3.4</concurrent.version>
647-
<netty.version>4.1.110.Final</netty.version>
647+
<netty.version>4.1.118.Final</netty.version>
648648
<cucumber.version>7.15.0</cucumber.version>
649649

650650
<jackson.version>2.17.1</jackson.version>

server/blob/blob-s3/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
<name>Apache James :: Server :: Blob :: S3</name>
3434

3535
<properties>
36-
<s3-sdk.version>2.26.5</s3-sdk.version>
36+
<s3-sdk.version>2.31.59</s3-sdk.version>
3737
</properties>
3838

3939
<dependencies>

server/blob/blob-s3/src/main/java/org/apache/james/blob/objectstorage/aws/S3ClientFactory.java

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,13 @@
4545

4646
import software.amazon.awssdk.auth.credentials.AwsBasicCredentials;
4747
import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider;
48+
import software.amazon.awssdk.core.checksums.RequestChecksumCalculation;
49+
import software.amazon.awssdk.core.checksums.ResponseChecksumValidation;
4850
import software.amazon.awssdk.http.TlsTrustManagersProvider;
4951
import software.amazon.awssdk.http.nio.netty.NettyNioAsyncHttpClient;
52+
import software.amazon.awssdk.services.s3.LegacyMd5Plugin;
5053
import software.amazon.awssdk.services.s3.S3AsyncClient;
54+
import software.amazon.awssdk.services.s3.S3AsyncClientBuilder;
5155
import software.amazon.awssdk.services.s3.S3Configuration;
5256

5357
@Singleton
@@ -72,6 +76,7 @@ public void checkServerTrusted(X509Certificate[] chain, String authType) {
7276
public static final String S3_METRICS_ENABLED_PROPERTY_KEY = "james.s3.metrics.enabled";
7377
public static final String S3_METRICS_ENABLED_DEFAULT_VALUE = "true";
7478
public static final String S3_METRICS_PREFIX = System.getProperty("james.s3.metrics.prefix", DEFAULT_S3_METRICS_PREFIX);
79+
public static final boolean S3_CHECKSUM_BACKWARD_COMPATIBILITY_ENABLED = Boolean.parseBoolean(System.getProperty("james.s3.sdk.checksum.backward.compatibility", "true"));
7580

7681
private final S3AsyncClient s3Client;
7782

@@ -86,7 +91,11 @@ public S3ClientFactory(S3BlobStoreConfiguration configuration, Provider<JamesS3M
8691
.pathStyleAccessEnabled(true)
8792
.build();
8893

89-
s3Client = S3AsyncClient.builder()
94+
s3Client = createS3AsyncClient(configuration, jamesS3MetricPublisherProvider, authConfiguration, pathStyleAccess);
95+
}
96+
97+
private S3AsyncClient createS3AsyncClient(S3BlobStoreConfiguration configuration, Provider<JamesS3MetricPublisher> jamesS3MetricPublisherProvider, AwsS3AuthConfiguration authConfiguration, S3Configuration pathStyleAccess) {
98+
S3AsyncClientBuilder s3AsyncClientBuilder = S3AsyncClient.builder()
9099
.credentialsProvider(StaticCredentialsProvider.create(
91100
AwsBasicCredentials.create(authConfiguration.getAccessKeyId(), authConfiguration.getSecretKey())))
92101
.httpClientBuilder(httpClientBuilder(configuration))
@@ -98,8 +107,16 @@ public S3ClientFactory(S3BlobStoreConfiguration configuration, Provider<JamesS3M
98107
if (s3MetricsEnabled) {
99108
builder.addMetricPublisher(jamesS3MetricPublisherProvider.get());
100109
}
101-
})
102-
.build();
110+
});
111+
112+
if (S3_CHECKSUM_BACKWARD_COMPATIBILITY_ENABLED) {
113+
s3AsyncClientBuilder
114+
.addPlugin(LegacyMd5Plugin.create())
115+
.requestChecksumCalculation(RequestChecksumCalculation.WHEN_REQUIRED)
116+
.responseChecksumValidation(ResponseChecksumValidation.WHEN_REQUIRED);
117+
}
118+
119+
return s3AsyncClientBuilder.build();
103120
}
104121

105122
private NettyNioAsyncHttpClient.Builder httpClientBuilder(S3BlobStoreConfiguration configuration) {

0 commit comments

Comments
 (0)