From c8195fb9b55bc71bd2afd255f8e9c40587968199 Mon Sep 17 00:00:00 2001 From: Artem Bilan Date: Thu, 30 Mar 2017 14:42:07 -0400 Subject: [PATCH] GH-56: Upgrade to SC-AWS-1.2 RC1 Fixes: spring-projects/spring-integration-aws#56 The upgrade to SC-AWS-1.2 RC1 resolves US_East_2 Region concern since AWS SDK is polled in version `1.1.98` Also fix deprecation warnings in S3 support components --- build.gradle | 2 +- .../aws/outbound/S3MessageHandler.java | 17 +++++++++++++---- .../aws/support/S3SessionFactory.java | 6 +++--- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/build.gradle b/build.gradle index 082375e..0dc11fb 100644 --- a/build.gradle +++ b/build.gradle @@ -37,7 +37,7 @@ ext { assertjVersion = '3.6.2' servletApiVersion = '3.1.0' slf4jVersion = '1.7.22' - springCloudAwsVersion = '1.1.3.RELEASE' + springCloudAwsVersion = '1.2.0.RC1' springIntegrationVersion = '4.3.8.RELEASE' idPrefix = 'aws' diff --git a/src/main/java/org/springframework/integration/aws/outbound/S3MessageHandler.java b/src/main/java/org/springframework/integration/aws/outbound/S3MessageHandler.java index c33a021..c3c4873 100644 --- a/src/main/java/org/springframework/integration/aws/outbound/S3MessageHandler.java +++ b/src/main/java/org/springframework/integration/aws/outbound/S3MessageHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 the original author or authors. + * Copyright 2016-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -50,6 +50,7 @@ import com.amazonaws.services.s3.transfer.ObjectMetadataProvider; import com.amazonaws.services.s3.transfer.PersistableTransfer; import com.amazonaws.services.s3.transfer.Transfer; import com.amazonaws.services.s3.transfer.TransferManager; +import com.amazonaws.services.s3.transfer.TransferManagerBuilder; import com.amazonaws.services.s3.transfer.internal.S3ProgressListener; import com.amazonaws.services.s3.transfer.internal.S3ProgressListenerChain; import com.amazonaws.util.Md5Utils; @@ -130,12 +131,20 @@ public class S3MessageHandler extends AbstractReplyProducingMessageHandler { } public S3MessageHandler(AmazonS3 amazonS3, String bucket, boolean produceReply) { - this(new TransferManager(amazonS3), bucket, produceReply); + this(TransferManagerBuilder.standard() + .withS3Client(amazonS3) + .build(), + bucket, + produceReply); Assert.notNull(amazonS3, "'amazonS3' must not be null"); } public S3MessageHandler(AmazonS3 amazonS3, Expression bucketExpression, boolean produceReply) { - this(new TransferManager(amazonS3), bucketExpression, produceReply); + this(TransferManagerBuilder.standard() + .withS3Client(amazonS3) + .build(), + bucketExpression, + produceReply); Assert.notNull(amazonS3, "'amazonS3' must not be null"); } @@ -319,7 +328,7 @@ public class S3MessageHandler extends AbstractReplyProducingMessageHandler { if (metadata.getContentMD5() == null) { Assert.state(inputStream.markSupported(), "For an upload InputStream with no MD5 digest metadata, the " + - "markSupported() method must evaluate to true. "); + "markSupported() method must evaluate to true. "); String contentMd5 = Md5Utils.md5AsBase64(inputStream); metadata.setContentMD5(contentMd5); inputStream.reset(); diff --git a/src/main/java/org/springframework/integration/aws/support/S3SessionFactory.java b/src/main/java/org/springframework/integration/aws/support/S3SessionFactory.java index 8eb4ac3..bfe19a3 100644 --- a/src/main/java/org/springframework/integration/aws/support/S3SessionFactory.java +++ b/src/main/java/org/springframework/integration/aws/support/S3SessionFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 the original author or authors. + * Copyright 2016-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,7 +22,7 @@ import org.springframework.integration.file.remote.session.SharedSessionCapable; import org.springframework.util.Assert; import com.amazonaws.services.s3.AmazonS3; -import com.amazonaws.services.s3.AmazonS3Client; +import com.amazonaws.services.s3.AmazonS3ClientBuilder; import com.amazonaws.services.s3.model.S3ObjectSummary; /** @@ -37,7 +37,7 @@ public class S3SessionFactory implements SessionFactory, Shared private final S3Session s3Session; public S3SessionFactory() { - this(new AmazonS3Client()); + this(AmazonS3ClientBuilder.defaultClient()); } public S3SessionFactory(AmazonS3 amazonS3) {