-
Notifications
You must be signed in to change notification settings - Fork 1k
Http Client made consistent with Default Proxy Configurations #4957
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 2 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
296dbc1
Http Client made consistent with Default Proxy Configurations
joviegas 4d2e472
made changes for URL client
joviegas 23e9db4
Updated test case Name
joviegas cdf1750
Updated comments related to test cases
joviegas 541a497
Merge branch 'master' into joviegas/proxy_config_consistent
joviegas 4385fb6
Updated change logs
joviegas 6ab357a
Merge branch 'master' into joviegas/proxy_config_consistent
joviegas b321a78
Updated test case to clear all System properties
joviegas 626e49d
Merge branch 'master' into joviegas/proxy_config_consistent
joviegas f64ecc1
Non Proxy configs should be independently picked up irrespective of P…
joviegas aac09a7
Revert "Non Proxy configs should be independently picked up irrespect…
joviegas 951ae74
Handled Zoes comments to close the client
joviegas e798edb
Merge branch 'master' into joviegas/proxy_config_consistent
joviegas 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| { | ||
| "type": "bugfix", | ||
| "category": "AWS SDK for Java v2", | ||
| "contributor": "", | ||
| "description": "Addressing Issue [#4745](https://github.com/aws/aws-sdk-java-v2/issues/4745) , Netty and CRT clients' default proxy settings have been made consistent with the Apache client, now using environment and system property settings by default.\n To disable the use of environment variables and system properties by default, set useSystemPropertyValue(false) and useEnvironmentVariablesValues(false) in ProxyConfigurations." | ||
| } | ||
65 changes: 65 additions & 0 deletions
65
.../src/test/java/software/amazon/awssdk/http/apache/ApacheClientProxyConfigurationTest.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,65 @@ | ||
| /* | ||
| * 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.http.apache; | ||
|
|
||
| import java.util.concurrent.ThreadLocalRandom; | ||
| import org.apache.http.conn.HttpHostConnectException; | ||
| import software.amazon.awssdk.http.SdkHttpClient; | ||
| import software.amazon.awssdk.http.async.SdkAsyncHttpClient; | ||
| import software.amazon.awssdk.http.proxy.HttpClientDefaultPoxyConfigTest; | ||
| import java.net.ConnectException; | ||
|
|
||
| public class ApacheClientProxyConfigurationTest extends HttpClientDefaultPoxyConfigTest { | ||
|
|
||
| @Override | ||
| protected Class<? extends Exception> getProxyFailedExceptionType() { | ||
| return HttpHostConnectException.class; | ||
|
|
||
| } | ||
|
|
||
| @Override | ||
| protected Class<? extends Exception> getProxyFailedCauseExceptionType() { | ||
| return ConnectException.class; | ||
| } | ||
|
|
||
| @Override | ||
| protected boolean isSyncClient() { | ||
| return true; | ||
| } | ||
|
|
||
| @Override | ||
| protected SdkAsyncHttpClient createHttpClientWithDefaultProxy() { | ||
| throw new IllegalArgumentException("Async client is not supported"); | ||
| } | ||
|
|
||
| @Override | ||
| protected SdkHttpClient createSyncHttpClientWithDefaultProxy() { | ||
| return ApacheHttpClient.builder().build(); | ||
| } | ||
|
|
||
| /** | ||
| * Wrire code which inputs an integer args and returns one number between 0 to 65535 excluding number args | ||
| */ | ||
| private int getRandomPort(int currentPort) { | ||
| int randomPort; | ||
| do { | ||
| randomPort = ThreadLocalRandom.current().nextInt(65535); | ||
| } while (randomPort == currentPort); | ||
| return randomPort; | ||
| } | ||
|
|
||
|
|
||
|
dagnir marked this conversation as resolved.
Outdated
|
||
| } | ||
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
50 changes: 50 additions & 0 deletions
50
...t/src/test/java/software/amazon/awssdk/http/crt/AsyncCrtClientProxyConfigurationTest.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,50 @@ | ||
| /* | ||
| * 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.http.crt; | ||
|
|
||
| import java.io.IOException; | ||
| import java.util.concurrent.ExecutionException; | ||
| import software.amazon.awssdk.http.SdkHttpClient; | ||
| import software.amazon.awssdk.http.async.SdkAsyncHttpClient; | ||
| import software.amazon.awssdk.http.proxy.HttpClientDefaultPoxyConfigTest; | ||
|
|
||
| public class AsyncCrtClientProxyConfigurationTest extends HttpClientDefaultPoxyConfigTest { | ||
|
|
||
| @Override | ||
| protected Class<? extends Exception> getProxyFailedExceptionType() { | ||
| return ExecutionException.class; | ||
| } | ||
|
|
||
| @Override | ||
| protected Class<? extends Exception> getProxyFailedCauseExceptionType() { | ||
| return IOException.class; | ||
| } | ||
|
|
||
| @Override | ||
| protected boolean isSyncClient() { | ||
| return false; | ||
| } | ||
|
|
||
| @Override | ||
| protected SdkAsyncHttpClient createHttpClientWithDefaultProxy() { | ||
| return AwsCrtAsyncHttpClient.builder().build(); | ||
| } | ||
|
|
||
| @Override | ||
| protected SdkHttpClient createSyncHttpClientWithDefaultProxy() { | ||
| throw new IllegalArgumentException("Sync client is not supported"); | ||
| } | ||
| } |
51 changes: 51 additions & 0 deletions
51
...nt/src/test/java/software/amazon/awssdk/http/crt/SyncCrtClientProxyConfigurationTest.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,51 @@ | ||
| /* | ||
| * 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.http.crt; | ||
|
|
||
|
|
||
| import java.io.IOException; | ||
| import software.amazon.awssdk.crt.http.HttpException; | ||
| import software.amazon.awssdk.http.SdkHttpClient; | ||
| import software.amazon.awssdk.http.async.SdkAsyncHttpClient; | ||
| import software.amazon.awssdk.http.proxy.HttpClientDefaultPoxyConfigTest; | ||
|
|
||
| public class SyncCrtClientProxyConfigurationTest extends HttpClientDefaultPoxyConfigTest { | ||
|
|
||
| @Override | ||
| protected Class<? extends Exception> getProxyFailedExceptionType() { | ||
| return IOException.class; | ||
| } | ||
|
|
||
| @Override | ||
| protected Class<? extends Exception> getProxyFailedCauseExceptionType() { | ||
| return HttpException.class; | ||
| } | ||
|
|
||
| @Override | ||
| protected boolean isSyncClient() { | ||
| return true; | ||
| } | ||
|
|
||
| @Override | ||
| protected SdkAsyncHttpClient createHttpClientWithDefaultProxy() { | ||
| throw new UnsupportedOperationException("Async client does not support proxy"); | ||
| } | ||
|
|
||
| @Override | ||
| protected SdkHttpClient createSyncHttpClientWithDefaultProxy() { | ||
| return AwsCrtHttpClient.create(); | ||
| } | ||
| } |
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
48 changes: 48 additions & 0 deletions
48
http-clients/netty-nio-client/src/test/java/NettyClientProxyConfigurationTest.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,48 @@ | ||
| /* | ||
| * 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. | ||
| */ | ||
|
|
||
| import java.net.ConnectException; | ||
| import java.util.concurrent.ExecutionException; | ||
| import software.amazon.awssdk.http.SdkHttpClient; | ||
| import software.amazon.awssdk.http.async.SdkAsyncHttpClient; | ||
| import software.amazon.awssdk.http.nio.netty.NettyNioAsyncHttpClient; | ||
| import software.amazon.awssdk.http.proxy.HttpClientDefaultPoxyConfigTest; | ||
|
|
||
| public class NettyClientProxyConfigurationTest extends HttpClientDefaultPoxyConfigTest { | ||
| @Override | ||
| protected boolean isSyncClient() { | ||
| return false; | ||
| } | ||
|
|
||
| @Override | ||
| protected SdkAsyncHttpClient createHttpClientWithDefaultProxy() { | ||
| return NettyNioAsyncHttpClient.create(); | ||
| } | ||
|
|
||
| @Override | ||
| protected SdkHttpClient createSyncHttpClientWithDefaultProxy() { | ||
| throw new IllegalArgumentException("Sync client not supported"); | ||
| } | ||
|
|
||
| @Override | ||
| protected Class<? extends Exception> getProxyFailedExceptionType() { | ||
| return ExecutionException.class; | ||
| } | ||
|
|
||
| @Override | ||
| protected Class<? extends Exception> getProxyFailedCauseExceptionType() { | ||
| return ConnectException.class; | ||
| } | ||
| } |
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
48 changes: 48 additions & 0 deletions
48
.../test/java/software/amazon/awssdk/http/urlconnection/UrlClientProxyConfigurationTest.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,48 @@ | ||
| /* | ||
| * 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.http.urlconnection; | ||
|
|
||
| import java.io.IOException; | ||
| import software.amazon.awssdk.http.SdkHttpClient; | ||
| import software.amazon.awssdk.http.async.SdkAsyncHttpClient; | ||
| import software.amazon.awssdk.http.proxy.HttpClientDefaultPoxyConfigTest; | ||
|
|
||
| public class UrlClientProxyConfigurationTest extends HttpClientDefaultPoxyConfigTest { | ||
| @Override | ||
| protected boolean isSyncClient() { | ||
| return true; | ||
| } | ||
|
|
||
| @Override | ||
| protected SdkAsyncHttpClient createHttpClientWithDefaultProxy() { | ||
| throw new UnsupportedOperationException("Async client not supported"); | ||
| } | ||
|
|
||
| @Override | ||
| protected SdkHttpClient createSyncHttpClientWithDefaultProxy() { | ||
| return UrlConnectionHttpClient.create(); | ||
| } | ||
|
|
||
| @Override | ||
| protected Class<? extends Exception> getProxyFailedExceptionType() { | ||
| return IOException.class; | ||
| } | ||
|
|
||
| @Override | ||
| protected Class<? extends Exception> getProxyFailedCauseExceptionType() { | ||
| return null; | ||
| } | ||
| } |
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.