Skip to content

Commit bc488d7

Browse files
authored
Merge pull request #2910 from aws/joviegas/revert_no_proxy
Revert "Support Non proxy host settings in the ProxyConfiguration for Crt http client. (#4962)"
2 parents 07cb686 + 7f5183c commit bc488d7

File tree

9 files changed

+11
-238
lines changed

9 files changed

+11
-238
lines changed

.changes/2.24.12.json

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,6 @@
1414
"contributor": "",
1515
"description": "We have added the ability to tag resources after they are created"
1616
},
17-
{
18-
"type": "feature",
19-
"category": "AWS CRT HTTP Client",
20-
"contributor": "",
21-
"description": "Support Non proxy host settings in the ProxyConfiguration for Crt http client."
22-
},
2317
{
2418
"type": "feature",
2519
"category": "Amazon S3",

CHANGELOG.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@
44
- ### Features
55
- We have added the ability to tag resources after they are created
66

7-
## __AWS CRT HTTP Client__
8-
- ### Features
9-
- Support Non proxy host settings in the ProxyConfiguration for Crt http client.
10-
117
## __AWS SDK for Java v2__
128
- ### Bugfixes
139
- upgrade netty version to 4.1.107.Final

core/crt-core/src/main/java/software/amazon/awssdk/crtcore/CrtConfigurationUtils.java

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,7 @@
1515

1616
package software.amazon.awssdk.crtcore;
1717

18-
import static software.amazon.awssdk.utils.StringUtils.lowerCase;
19-
20-
import java.util.Objects;
2118
import java.util.Optional;
22-
import java.util.Set;
2319
import software.amazon.awssdk.annotations.SdkProtectedApi;
2420
import software.amazon.awssdk.crt.http.HttpMonitoringOptions;
2521
import software.amazon.awssdk.crt.http.HttpProxyOptions;
@@ -37,9 +33,7 @@ public static Optional<HttpProxyOptions> resolveProxy(CrtProxyConfiguration prox
3733
if (proxyConfiguration == null) {
3834
return Optional.empty();
3935
}
40-
if (doesTargetMatchNonProxyHosts(proxyConfiguration.host(), proxyConfiguration.nonProxyHosts())) {
41-
return Optional.empty();
42-
}
36+
4337
HttpProxyOptions clientProxyOptions = new HttpProxyOptions();
4438

4539
clientProxyOptions.setHost(proxyConfiguration.host());
@@ -60,19 +54,11 @@ public static Optional<HttpProxyOptions> resolveProxy(CrtProxyConfiguration prox
6054
return Optional.of(clientProxyOptions);
6155
}
6256

63-
private static boolean doesTargetMatchNonProxyHosts(String target, Set<String> hostPatterns) {
64-
return Optional.ofNullable(hostPatterns)
65-
.map(patterns ->
66-
patterns.stream()
67-
.filter(Objects::nonNull)
68-
.anyMatch(pattern -> target != null && lowerCase(target).matches(pattern)))
69-
.orElse(false);
70-
}
71-
7257
public static Optional<HttpMonitoringOptions> resolveHttpMonitoringOptions(CrtConnectionHealthConfiguration config) {
7358
if (config == null) {
7459
return Optional.empty();
7560
}
61+
7662
HttpMonitoringOptions httpMonitoringOptions = new HttpMonitoringOptions();
7763
httpMonitoringOptions.setMinThroughputBytesPerSecond(config.minimumThroughputInBps());
7864
int seconds = NumericUtils.saturatedCast(config.minimumThroughputTimeout().getSeconds());

core/crt-core/src/main/java/software/amazon/awssdk/crtcore/CrtProxyConfiguration.java

Lines changed: 1 addition & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@
1717

1818
import static software.amazon.awssdk.utils.ProxyConfigProvider.fromSystemEnvironmentSettings;
1919

20-
import java.util.Collections;
21-
import java.util.HashSet;
2220
import java.util.Objects;
23-
import java.util.Set;
2421
import software.amazon.awssdk.annotations.SdkPublicApi;
2522
import software.amazon.awssdk.utils.ProxyConfigProvider;
2623
import software.amazon.awssdk.utils.ProxySystemSetting;
@@ -39,7 +36,6 @@ public abstract class CrtProxyConfiguration {
3936
private final String password;
4037
private final Boolean useSystemPropertyValues;
4138
private final Boolean useEnvironmentVariableValues;
42-
private final Set<String> nonProxyHosts;
4339

4440
protected CrtProxyConfiguration(DefaultBuilder<?> builder) {
4541
this.useSystemPropertyValues = builder.useSystemPropertyValues;
@@ -53,7 +49,6 @@ protected CrtProxyConfiguration(DefaultBuilder<?> builder) {
5349
this.port = resolvePort(builder, proxyConfigProvider);
5450
this.username = resolveUsername(builder, proxyConfigProvider);
5551
this.password = resolvePassword(builder, proxyConfigProvider);
56-
this.nonProxyHosts = resolveNonProxyHosts(builder, proxyConfigProvider);
5752
}
5853

5954
private static String resolvePassword(DefaultBuilder<?> builder, ProxyConfigProvider proxyConfigProvider) {
@@ -88,13 +83,6 @@ private static String resolveHost(DefaultBuilder<?> builder, ProxyConfigProvider
8883
}
8984
}
9085

91-
private Set<String> resolveNonProxyHosts(DefaultBuilder<?> builder, ProxyConfigProvider proxyConfigProvider) {
92-
if (builder.nonProxyHosts != null || proxyConfigProvider == null) {
93-
return builder.nonProxyHosts;
94-
}
95-
return proxyConfigProvider.nonProxyHosts();
96-
}
97-
9886
/**
9987
* @return The proxy scheme.
10088
*/
@@ -144,16 +132,6 @@ public final Boolean isUseEnvironmentVariableValues() {
144132
return useEnvironmentVariableValues;
145133
}
146134

147-
/**
148-
* Retrieves the hosts that the client is allowed to access without going through the proxy.
149-
* If the value is not set on the object, the value represented by the environment variable or system property is returned.
150-
*
151-
* @see Builder#nonProxyHosts(Set)
152-
*/
153-
public Set<String> nonProxyHosts() {
154-
return Collections.unmodifiableSet(nonProxyHosts != null ? nonProxyHosts : Collections.emptySet());
155-
}
156-
157135
@Override
158136
public boolean equals(Object o) {
159137
if (this == o) {
@@ -184,10 +162,7 @@ public boolean equals(Object o) {
184162
if (!Objects.equals(useSystemPropertyValues, that.useSystemPropertyValues)) {
185163
return false;
186164
}
187-
if (!Objects.equals(useEnvironmentVariableValues, that.useEnvironmentVariableValues)) {
188-
return false;
189-
}
190-
return Objects.equals(nonProxyHosts, that.nonProxyHosts);
165+
return Objects.equals(useEnvironmentVariableValues, that.useEnvironmentVariableValues);
191166
}
192167

193168
@Override
@@ -200,7 +175,6 @@ public int hashCode() {
200175
result = 31 * result + (useSystemPropertyValues != null ? useSystemPropertyValues.hashCode() : 0);
201176
result = 31 * result + (useEnvironmentVariableValues != null ? useEnvironmentVariableValues.hashCode() : 0);
202177
result = 31 * result + (scheme != null ? scheme.hashCode() : 0);
203-
result = 31 * result + (nonProxyHosts != null ? nonProxyHosts.hashCode() : 0);
204178
return result;
205179
}
206180

@@ -279,17 +253,6 @@ public interface Builder {
279253
*/
280254
Builder useEnvironmentVariableValues(Boolean useEnvironmentVariableValues);
281255

282-
/**
283-
* Configure the hosts that the client is allowed to access without going through the proxy.
284-
*/
285-
Builder nonProxyHosts(Set<String> nonProxyHosts);
286-
287-
288-
/**
289-
* Add a host that the client is allowed to access without going through the proxy.
290-
*/
291-
Builder addNonProxyHost(String nonProxyHost);
292-
293256

294257
CrtProxyConfiguration build();
295258
}
@@ -303,8 +266,6 @@ protected abstract static class DefaultBuilder<B extends Builder> implements Bui
303266
private String password;
304267
private Boolean useSystemPropertyValues = Boolean.TRUE;
305268
private Boolean useEnvironmentVariableValues = Boolean.TRUE;
306-
private Set<String> nonProxyHosts;
307-
308269

309270
protected DefaultBuilder() {
310271
}
@@ -317,7 +278,6 @@ protected DefaultBuilder(CrtProxyConfiguration proxyConfiguration) {
317278
this.port = proxyConfiguration.port;
318279
this.username = proxyConfiguration.username;
319280
this.password = proxyConfiguration.password;
320-
this.nonProxyHosts = proxyConfiguration.nonProxyHosts;
321281
}
322282

323283
@Override
@@ -362,21 +322,6 @@ public B useEnvironmentVariableValues(Boolean useEnvironmentVariableValues) {
362322
return (B) this;
363323
}
364324

365-
@Override
366-
public B nonProxyHosts(Set<String> nonProxyHosts) {
367-
this.nonProxyHosts = nonProxyHosts != null ? new HashSet<>(nonProxyHosts) : null;
368-
return (B) this;
369-
}
370-
371-
@Override
372-
public B addNonProxyHost(String nonProxyHost) {
373-
if (this.nonProxyHosts == null) {
374-
this.nonProxyHosts = new HashSet<>();
375-
}
376-
this.nonProxyHosts.add(nonProxyHost);
377-
return (B) this;
378-
}
379-
380325
public B setuseEnvironmentVariableValues(Boolean useEnvironmentVariableValues) {
381326
return useEnvironmentVariableValues(useEnvironmentVariableValues);
382327
}

core/crt-core/src/test/java/software/amazon/awssdk/crtcore/CrtConnectionUtilsTest.java

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,7 @@
2020

2121
import java.time.Duration;
2222
import java.util.Optional;
23-
import java.util.stream.Collectors;
24-
import java.util.stream.Stream;
2523
import org.junit.jupiter.api.Test;
26-
import org.junit.jupiter.params.ParameterizedTest;
27-
import org.junit.jupiter.params.provider.ValueSource;
2824
import org.mockito.Mockito;
2925
import software.amazon.awssdk.crt.http.HttpMonitoringOptions;
3026
import software.amazon.awssdk.crt.http.HttpProxyOptions;
@@ -58,60 +54,6 @@ void resolveProxy_emptyProxy_shouldReturnEmpty() {
5854
assertThat(CrtConfigurationUtils.resolveProxy(null, tlsContext)).isEmpty();
5955
}
6056

61-
@ParameterizedTest
62-
@ValueSource(strings = {".*?.2.3.4", "1.*?.3.4", ".*?"})
63-
void resolveProxy_withSingleNonProxyHostsWidCards_shouldReturnEmpty(String nonProxyHost) {
64-
TlsContext tlsContext = Mockito.mock(TlsContext.class);
65-
CrtProxyConfiguration configuration = new TestProxy.Builder().host("1.2.3.4")
66-
.port(123)
67-
.scheme("https")
68-
.password("bar")
69-
.username("foo")
70-
.nonProxyHosts(Stream.of(nonProxyHost,"someRandom")
71-
.collect(Collectors.toSet()))
72-
.build();
73-
assertThat(CrtConfigurationUtils.resolveProxy(configuration, tlsContext)).isEmpty();
74-
}
75-
76-
77-
78-
@Test
79-
void resolveProxy_withNullHostAndNonPorxy_shouldNotReturnEmpty( ) {
80-
TlsContext tlsContext = Mockito.mock(TlsContext.class);
81-
CrtProxyConfiguration configuration = new TestProxy.Builder().host(null)
82-
.port(123)
83-
.scheme("https")
84-
.password("bar")
85-
.username("foo")
86-
.nonProxyHosts(Stream.of("someRandom", "null")
87-
.collect(Collectors.toSet()))
88-
.build();
89-
assertThat(CrtConfigurationUtils.resolveProxy(configuration, tlsContext)).isNotEmpty();
90-
}
91-
92-
@Test
93-
void resolveProxy_basicAuthorization_WithNonMatchingNoProxy() {
94-
CrtProxyConfiguration configuration = new TestProxy.Builder().host("1.2.3.4")
95-
.port(123)
96-
.scheme("https")
97-
.password("bar")
98-
.addNonProxyHost("someRandom")
99-
.addNonProxyHost(null)
100-
.username("foo")
101-
.build();
102-
103-
TlsContext tlsContext = Mockito.mock(TlsContext.class);
104-
105-
Optional<HttpProxyOptions> httpProxyOptions = CrtConfigurationUtils.resolveProxy(configuration, tlsContext);
106-
assertThat(httpProxyOptions).hasValueSatisfying(proxy -> {
107-
assertThat(proxy.getTlsContext()).isEqualTo(tlsContext);
108-
assertThat(proxy.getAuthorizationPassword()).isEqualTo("bar");
109-
assertThat(proxy.getAuthorizationUsername()).isEqualTo("foo");
110-
assertThat(proxy.getAuthorizationType()).isEqualTo(HttpProxyOptions.HttpProxyAuthorizationType.Basic);
111-
});
112-
}
113-
114-
11557
@Test
11658
void resolveProxy_noneAuthorization() {
11759
CrtProxyConfiguration configuration = new TestProxy.Builder().host("1.2.3.4")

http-clients/aws-crt-client/src/main/java/software/amazon/awssdk/http/crt/ProxyConfiguration.java

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,8 @@
1515

1616
package software.amazon.awssdk.http.crt;
1717

18-
import java.util.Set;
1918
import software.amazon.awssdk.annotations.SdkPublicApi;
2019
import software.amazon.awssdk.crtcore.CrtProxyConfiguration;
21-
import software.amazon.awssdk.utils.ProxyEnvironmentSetting;
2220
import software.amazon.awssdk.utils.ProxySystemSetting;
2321
import software.amazon.awssdk.utils.builder.CopyableBuilder;
2422
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
@@ -118,35 +116,9 @@ public interface Builder extends CrtProxyConfiguration.Builder, CopyableBuilder<
118116
Builder useSystemPropertyValues(Boolean useSystemPropertyValues);
119117

120118

121-
/**
122-
* Set the option whether to use environment variable values for {@link ProxyEnvironmentSetting} if any of the config
123-
* options are missing. The value is set to "true" by default, enabling the SDK to automatically use environment variable
124-
* values for proxy configuration options that are not provided during building the {@link ProxyConfiguration} object. To
125-
* disable this behavior, set this value to "false".It is important to note that when this property is set to "true," all
126-
* proxy settings will exclusively originate from Environment Variable Values, and no partial settings will be obtained
127-
* from System Property Values.
128-
* <p>Comma-separated host names in the NO_PROXY environment variable indicate multiple hosts to exclude from
129-
* proxy settings.
130-
*
131-
* @param useEnvironmentVariableValues The option whether to use environment variable values
132-
* @return This object for method chaining.
133-
*/
134119
@Override
135120
Builder useEnvironmentVariableValues(Boolean useEnvironmentVariableValues);
136121

137-
/**
138-
* Configure the hosts that the client is allowed to access without going through the proxy.
139-
*/
140-
@Override
141-
Builder nonProxyHosts(Set<String> nonProxyHosts);
142-
143-
144-
/**
145-
* Add a host that the client is allowed to access without going through the proxy.
146-
*/
147-
@Override
148-
Builder addNonProxyHost(String nonProxyHost);
149-
150122
@Override
151123
ProxyConfiguration build();
152124
}

http-clients/aws-crt-client/src/test/java/software/amazon/awssdk/http/crt/CrtHttpProxyTest.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import static org.assertj.core.api.Assertions.assertThat;
1919

2020
import java.net.URISyntaxException;
21-
import java.util.Set;
2221
import software.amazon.awssdk.http.HttpProxyTestSuite;
2322
import software.amazon.awssdk.http.proxy.TestProxySetting;
2423

@@ -36,7 +35,6 @@ protected void assertProxyConfiguration(TestProxySetting userSetProxySettings,
3635
Integer portNumber = userSetProxySettings.getPort();
3736
String userName = userSetProxySettings.getUserName();
3837
String password = userSetProxySettings.getPassword();
39-
Set<String> nonProxyHosts = userSetProxySettings.getNonProxyHosts();
4038

4139
if (hostName != null) {
4240
proxyBuilder.host(hostName);
@@ -50,9 +48,6 @@ protected void assertProxyConfiguration(TestProxySetting userSetProxySettings,
5048
if (password != null) {
5149
proxyBuilder.password(password);
5250
}
53-
if (nonProxyHosts != null && !nonProxyHosts.isEmpty()) {
54-
proxyBuilder.nonProxyHosts(nonProxyHosts);
55-
}
5651
}
5752

5853
if (!"http".equals(protocol)) {
@@ -69,7 +64,6 @@ protected void assertProxyConfiguration(TestProxySetting userSetProxySettings,
6964
assertThat(proxyConfiguration.port()).isEqualTo(expectedProxySettings.getPort());
7065
assertThat(proxyConfiguration.username()).isEqualTo(expectedProxySettings.getUserName());
7166
assertThat(proxyConfiguration.password()).isEqualTo(expectedProxySettings.getPassword());
72-
assertThat(proxyConfiguration.nonProxyHosts()).isEqualTo(expectedProxySettings.getNonProxyHosts());
7367
}
7468

7569
}

http-clients/aws-crt-client/src/test/java/software/amazon/awssdk/http/crt/ProxyConfigurationTest.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,7 @@
1919

2020
import java.lang.reflect.InvocationTargetException;
2121
import java.lang.reflect.Method;
22-
import java.util.HashSet;
2322
import java.util.Random;
24-
import java.util.Set;
25-
import java.util.stream.Collectors;
26-
import java.util.stream.IntStream;
2723
import java.util.stream.Stream;
2824
import org.junit.jupiter.api.AfterAll;
2925
import org.junit.jupiter.api.BeforeEach;
@@ -185,8 +181,6 @@ private void setRandomValue(Object o, Method setter) throws InvocationTargetExce
185181
setter.invoke(o, RNG.nextInt());
186182
} else if (Boolean.class.equals(paramClass)) {
187183
setter.invoke(o, RNG.nextBoolean());
188-
} else if (Set.class.equals(paramClass)) {
189-
setter.invoke(o, IntStream.range(0, 5).mapToObj(i -> randomString()).collect(Collectors.toSet()));
190184
} else {
191185
throw new RuntimeException("Don't know how create random value for type " + paramClass);
192186
}

0 commit comments

Comments
 (0)