awsdocs/aws-java-developer-guide

java.lang.UnsupportedOperationException when using AmazonS3EncryptionClient with TransferUtility [Urgent]

hs8058 opened this issue · 1 comments

Hi,

Has anyone tried using AmazonS3EncryptionClient with TransferUtility?

Irrespective of the chosen CryptoConfiguration, when ObjectMetadata.addUserMetadata is internally called during the building of the putobject request, an exception is raised, which is apparently the result of ObjectMetadata.usermetadata being an UnmodifiableMap, which makes it impossible to add the required custom meta data:

When using AmazonS3EncryptionClient.putObject directly (not using TransferUtility), such an error does not happen.

This is urgent.

Here is the exception:

java.lang.UnsupportedOperationException
at java.util.Collections$UnmodifiableMap.put(Collections.java:1280)
at com.amazonaws.services.s3.model.ObjectMetadata.addUserMetadata(ObjectMetadata.java:196)
at com.amazonaws.services.s3.internal.crypto.EncryptionUtils.encryptRequestUsingInstruction(EncryptionUtils.java:362)
at com.amazonaws.services.s3.internal.crypto.S3CryptoModuleEO.putObjectUsingInstructionFile(S3CryptoModuleEO.java:354)
at com.amazonaws.services.s3.internal.crypto.S3CryptoModuleEO.putObjectSecurely(S3CryptoModuleEO.java:87)
at com.amazonaws.services.s3.internal.crypto.CryptoModuleDispatcher.putObjectSecurely(CryptoModuleDispatcher.java:85)
at com.amazonaws.services.s3.AmazonS3EncryptionClient.putObject(AmazonS3EncryptionClient.java:412)
at com.amazonaws.mobileconnectors.s3.transferutility.UploadTask.uploadSinglePartAndWaitForCompletion(UploadTask.java:203)
at com.amazonaws.mobileconnectors.s3.transferutility.UploadTask.call(UploadTask.java:85)
at com.amazonaws.mobileconnectors.s3.transferutility.UploadTask.call(UploadTask.java:44)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:841)

Hello @hs8058. This is the repository for the AWS Java Developer Guide.

The AWS Java Forum or the AWS Java SDK Gitter channel are better places to ask questions about the SDK. If your case is urgent, then you should probably contact your AWS support representative.

That said, there is a note in the TransferManager reference documentation:

TransferManager doesn't support copying of encrypted objects whose encryption materials are stored in an instruction file.

Is this the case with your object?

If not, then it may be a bug in the SDK. Here's the location of the AWS SDK for Java's repo:

https://github.com/aws/aws-sdk-java

and associated Issues page:

https://github.com/aws/aws-sdk-java/issues

Thanks much!