-
Notifications
You must be signed in to change notification settings - Fork 916
Async interceptor payload + S3 Checksums #823
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
188 changes: 95 additions & 93 deletions
188
...src/test/resources/software/amazon/awssdk/codegen/poet/client/test-json-client-class.java
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
core/sdk-core/src/main/java/software/amazon/awssdk/core/ClientType.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Copyright 2010-2018 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.core; | ||
|
||
import software.amazon.awssdk.annotations.SdkPublicApi; | ||
|
||
/** | ||
* Enum that represents the type of client being used. | ||
*/ | ||
@SdkPublicApi | ||
public enum ClientType { | ||
|
||
ASYNC("Async"), | ||
SYNC("Sync"); | ||
|
||
private final String clientType; | ||
|
||
ClientType(String clientType) { | ||
this.clientType = clientType; | ||
} | ||
|
||
/* (non-Javadoc) | ||
* @see java.lang.Enum#toString() | ||
*/ | ||
@Override | ||
public String toString() { | ||
return clientType; | ||
} | ||
} |
84 changes: 84 additions & 0 deletions
84
core/sdk-core/src/main/java/software/amazon/awssdk/core/checksums/Md5Checksum.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/* | ||
* Copyright 2010-2018 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.core.checksums; | ||
|
||
import java.security.MessageDigest; | ||
import software.amazon.awssdk.annotations.SdkInternalApi; | ||
|
||
/** | ||
* Implementation of {@link SdkChecksum} to calculate an MD5 checksum. | ||
*/ | ||
@SdkInternalApi | ||
public class Md5Checksum implements SdkChecksum { | ||
|
||
private MessageDigest digest; | ||
|
||
private MessageDigest digestLastMarked; | ||
|
||
public Md5Checksum() { | ||
this.digest = getDigest(); | ||
} | ||
|
||
@Override | ||
public void update(int b) { | ||
digest.update((byte) b); | ||
} | ||
|
||
@Override | ||
public void update(byte[] b, int off, int len) { | ||
digest.update(b, off, len); | ||
} | ||
|
||
@Override | ||
public long getValue() { | ||
throw new UnsupportedOperationException("Use getChecksumBytes() instead."); | ||
} | ||
|
||
@Override | ||
public void reset() { | ||
digest = (digestLastMarked == null) | ||
// This is necessary so that should there be a reset without a | ||
// preceding mark, the MD5 would still be computed correctly. | ||
? getDigest() | ||
: cloneFrom(digestLastMarked); | ||
} | ||
|
||
private MessageDigest getDigest() { | ||
try { | ||
return MessageDigest.getInstance("MD5"); | ||
} catch (Exception e) { | ||
throw new IllegalStateException("Unexpected error creating MD5 checksum", e); | ||
} | ||
} | ||
|
||
@Override | ||
public byte[] getChecksumBytes() { | ||
return digest.digest(); | ||
} | ||
|
||
@Override | ||
public void mark(int readLimit) { | ||
digestLastMarked = cloneFrom(digest); | ||
} | ||
|
||
private MessageDigest cloneFrom(MessageDigest from) { | ||
try { | ||
return (MessageDigest) from.clone(); | ||
} catch (CloneNotSupportedException e) { // should never occur | ||
throw new IllegalStateException("unexpected", e); | ||
} | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
core/sdk-core/src/main/java/software/amazon/awssdk/core/checksums/SdkChecksum.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Copyright 2010-2018 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.core.checksums; | ||
|
||
import java.util.zip.Checksum; | ||
import software.amazon.awssdk.annotations.SdkPublicApi; | ||
|
||
/** | ||
* Extension of {@link Checksum} to support checksums and checksum validations used by the SDK that | ||
* are not provided by the JDK. | ||
*/ | ||
@SdkPublicApi | ||
public interface SdkChecksum extends Checksum { | ||
|
||
/** | ||
* Returns the computed checksum in a byte array rather than the long provided by | ||
* {@link #getValue()}. | ||
* | ||
* @return byte[] containing the checksum | ||
*/ | ||
byte[] getChecksumBytes(); | ||
|
||
/** | ||
* Allows marking a checksum for checksums that support the ability to mark and reset. | ||
* | ||
* @param readLimit the maximum limit of bytes that can be read before the mark position becomes invalid. | ||
*/ | ||
void mark(int readLimit); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.