-
Notifications
You must be signed in to change notification settings - Fork 919
Refactor tryDetectRegion Method . Remove aws-json-protocol dependency #3324
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
Open
srsaikumarreddy
wants to merge
3
commits into
aws:feature/master/imds
Choose a base branch
from
srsaikumarreddy:saikred/feature/regionProvider
base: feature/master/imds
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 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
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -30,7 +30,7 @@ | |||
import software.amazon.awssdk.http.HttpExecuteResponse; | ||||
import software.amazon.awssdk.http.SdkHttpClient; | ||||
import software.amazon.awssdk.http.SdkHttpMethod; | ||||
import software.amazon.awssdk.http.urlconnection.UrlConnectionHttpClient; | ||||
import software.amazon.awssdk.http.apache.ApacheHttpClient; | ||||
import software.amazon.awssdk.imds.Ec2Metadata; | ||||
import software.amazon.awssdk.imds.Ec2MetadataRetryPolicy; | ||||
import software.amazon.awssdk.imds.MetadataResponse; | ||||
|
@@ -72,7 +72,7 @@ private DefaultEc2Metadata(DefaultEc2Metadata.Ec2MetadataBuilder builder) { | |||
this.tokenTtl = builder.tokenTtl != null ? builder.tokenTtl : Duration.ofSeconds(21600); | ||||
this.endpointMode = ENDPOINT_PROVIDER.resolveEndpointMode(builder.endpointMode); | ||||
this.httpDebugOutput = builder.httpDebugOutput; | ||||
this.httpClient = builder.httpClient != null ? builder.httpClient : UrlConnectionHttpClient.create(); | ||||
this.httpClient = builder.httpClient != null ? builder.httpClient : ApacheHttpClient.create(); | ||||
joviegas marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This would cause build to fail for applications that only have/use UrlConnectionHttpClient as HTTP dependency. Line 30 in e320d12
|
||||
} | ||||
|
||||
public static Ec2Metadata.Builder builder() { | ||||
|
69 changes: 69 additions & 0 deletions
69
...n/java/software/amazon/awssdk/imds/internal/unmarshall/document/DocumentUnmarshaller.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,69 @@ | ||
/* | ||
* Copyright 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.imds.internal.unmarshall.document; | ||
|
||
import java.util.LinkedHashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.stream.Collectors; | ||
import software.amazon.awssdk.annotations.SdkInternalApi; | ||
import software.amazon.awssdk.core.document.Document; | ||
import software.amazon.awssdk.protocols.jsoncore.JsonNode; | ||
import software.amazon.awssdk.protocols.jsoncore.JsonNodeVisitor; | ||
|
||
@SdkInternalApi | ||
public class DocumentUnmarshaller implements JsonNodeVisitor<Document> { | ||
@Override | ||
public Document visitNull() { | ||
return Document.fromNull(); | ||
} | ||
|
||
@Override | ||
public Document visitBoolean(boolean bool) { | ||
return Document.fromBoolean(bool); | ||
} | ||
|
||
@Override | ||
public Document visitNumber(String number) { | ||
return Document.fromNumber(number); | ||
} | ||
|
||
@Override | ||
public Document visitString(String string) { | ||
return Document.fromString(string); | ||
} | ||
|
||
@Override | ||
public Document visitArray(List<JsonNode> array) { | ||
return Document.fromList(array.stream() | ||
.map(node -> node.visit(this)) | ||
.collect(Collectors.toList())); | ||
} | ||
|
||
@Override | ||
public Document visitObject(Map<String, JsonNode> object) { | ||
return Document.fromMap(object.entrySet() | ||
.stream().collect(Collectors.toMap(entry -> entry.getKey(), | ||
entry -> entry.getValue().visit(this), | ||
(left, right) -> left, | ||
LinkedHashMap::new))); | ||
} | ||
|
||
@Override | ||
public Document visitEmbeddedObject(Object embeddedObject) { | ||
throw new UnsupportedOperationException("Embedded objects are not supported within Document types."); | ||
} | ||
} |
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
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.