Skip to content
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

[BEAM-3813] Support (de)serialization of S3 encryption options via JSON #5491

Merged
merged 1 commit into from May 29, 2018

Conversation

iemejia
Copy link
Member

@iemejia iemejia commented May 25, 2018

Following your remarks, I reused the same JIRA ticket since this is related. PTAL
R: @lukecwik

@iemejia iemejia requested a review from lukecwik May 25, 2018 21:26
* A Jackson {@link Module} that registers a {@link JsonDeserializer} for {@link SSECustomerKey} and
* {@link SSEAwsKeyManagementParams}. The serialized form is based on a Bean serialization.
*/
@AutoService(Module.class)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason now to put the extra serializers/deserializes into AwsModule.java?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I just thought since they corresponded to a different object S3Options they would be good in their own module but I can put all in AwsModule if you think it is better.

final String algorithm =
node.get("algorithm") != null ? node.get("algorithm").textValue() : null;
final String md5 = node.get("md5") != null ? node.get("md5").textValue() : null;
return new SSECustomerKey(key).withAlgorithm(algorithm).withMd5(md5);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Annoyingly, passing in null doesn't have the SSECustomerKey set the defaults: https://github.com/aws/aws-sdk-java/blob/master/aws-java-sdk-s3/src/main/java/com/amazonaws/services/s3/model/SSECustomerKey.java#L162

We should only call withYYY if the user specified YYY in the JSON.

@Override
public SSECustomerKey deserialize(JsonParser parser, DeserializationContext context)
throws IOException {
JsonNode node = parser.getCodec().readTree(parser);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be easier to read if you convert the value into a Map<String, String> using:

Map<String, String> asMap =
          jsonParser.readValueAs(new TypeReference<Map<String, String>>() {
          });

ditto on below.

}

@Test
public void testSSECustomerKeySerializationDeserialization() throws Exception {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try a test where you set the minimal set of properties.

@iemejia
Copy link
Member Author

iemejia commented May 29, 2018

Fixes done. PTAL again @lukecwik

@iemejia
Copy link
Member Author

iemejia commented May 29, 2018

Thanks for the review @lukecwik , it really improved it by making it simpler.

@iemejia iemejia merged commit 9fbfb68 into apache:master May 29, 2018
@iemejia iemejia deleted the fix-s3-json-options branch May 29, 2018 21:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants