Skip to content

Clean up unused APIs and add test to make sure it can be handled with alternatives #6211

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 2 commits into from
Jun 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* 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.net.InetAddress;
import java.time.Duration;
import org.junit.jupiter.api.DisplayName;
import software.amazon.awssdk.http.SdkHttpClient;
import software.amazon.awssdk.http.SdkHttpClientLocalAddressFunctionalTestSuite;

@DisplayName("Apache HTTP Client - Local Address Functional Tests")
class ApacheHttpClientLocalAddressFunctionalTest extends SdkHttpClientLocalAddressFunctionalTestSuite {

@Override
protected SdkHttpClient createHttpClient(InetAddress localAddress, Duration connectionTimeout) {
return ApacheHttpClient.builder()
.localAddress(localAddress)
.connectionTimeout(connectionTimeout)
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.net.InetAddress;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.CertificateException;
Expand Down Expand Up @@ -338,7 +337,6 @@ private Apache5HttpRequestConfig createRequestConfig(DefaultBuilder builder,
.connectionAcquireTimeout(
resolvedOptions.get(SdkHttpConfigurationOption.CONNECTION_ACQUIRE_TIMEOUT))
.proxyConfiguration(builder.proxyConfiguration)
.localAddress(Optional.ofNullable(builder.localAddress).orElse(null))
.expectContinueEnabled(Optional.ofNullable(builder.expectContinueEnabled)
.orElse(DefaultConfiguration.EXPECT_CONTINUE_ENABLED))
.build();
Expand Down Expand Up @@ -406,11 +404,6 @@ public interface Builder extends SdkHttpClient.Builder<Apache5HttpClient.Builder
*/
Builder proxyConfiguration(ProxyConfiguration proxyConfiguration);

/**
* Configure the local address that the HTTP client should use for communication.
*/
Builder localAddress(InetAddress localAddress);

/**
* Configure whether the client should send an HTTP expect-continue handshake before each request.
*/
Expand Down Expand Up @@ -498,7 +491,6 @@ private static final class DefaultBuilder implements Builder {
private final AttributeMap.Builder standardOptions = AttributeMap.builder();
private Registry<AuthSchemeFactory> authSchemeRegistry;
private ProxyConfiguration proxyConfiguration = ProxyConfiguration.builder().build();
private InetAddress localAddress;
private Boolean expectContinueEnabled;
private HttpRoutePlanner httpRoutePlanner;
private CredentialsProvider credentialsProvider;
Expand Down Expand Up @@ -564,16 +556,6 @@ public void setProxyConfiguration(ProxyConfiguration proxyConfiguration) {
proxyConfiguration(proxyConfiguration);
}

@Override
public Builder localAddress(InetAddress localAddress) {
this.localAddress = localAddress;
return this;
}

public void setLocalAddress(InetAddress localAddress) {
localAddress(localAddress);
}

@Override
public Builder expectContinueEnabled(Boolean expectContinueEnabled) {
this.expectContinueEnabled = expectContinueEnabled;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

package software.amazon.awssdk.http.apache5.internal;

import java.net.InetAddress;
import java.time.Duration;
import software.amazon.awssdk.annotations.SdkInternalApi;
import software.amazon.awssdk.http.apache5.ProxyConfiguration;
Expand All @@ -30,15 +29,13 @@ public final class Apache5HttpRequestConfig {
private final Duration socketTimeout;
private final Duration connectionTimeout;
private final Duration connectionAcquireTimeout;
private final InetAddress localAddress;
private final boolean expectContinueEnabled;
private final ProxyConfiguration proxyConfiguration;

private Apache5HttpRequestConfig(Builder builder) {
this.socketTimeout = builder.socketTimeout;
this.connectionTimeout = builder.connectionTimeout;
this.connectionAcquireTimeout = builder.connectionAcquireTimeout;
this.localAddress = builder.localAddress;
this.expectContinueEnabled = builder.expectContinueEnabled;
this.proxyConfiguration = builder.proxyConfiguration;
}
Expand All @@ -55,10 +52,6 @@ public Duration connectionAcquireTimeout() {
return connectionAcquireTimeout;
}

public InetAddress localAddress() {
return localAddress;
}

public boolean expectContinueEnabled() {
return expectContinueEnabled;
}
Expand All @@ -82,7 +75,6 @@ public static final class Builder {
private Duration socketTimeout;
private Duration connectionTimeout;
private Duration connectionAcquireTimeout;
private InetAddress localAddress;
private boolean expectContinueEnabled;
private ProxyConfiguration proxyConfiguration;

Expand All @@ -104,11 +96,6 @@ public Builder connectionAcquireTimeout(Duration connectionAcquireTimeout) {
return this;
}

public Builder localAddress(InetAddress localAddress) {
this.localAddress = localAddress;
return this;
}

public Builder expectContinueEnabled(boolean expectContinueEnabled) {
this.expectContinueEnabled = expectContinueEnabled;
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@
import org.apache.hc.core5.http.protocol.HttpContext;
import org.apache.hc.core5.util.TimeValue;
import software.amazon.awssdk.annotations.SdkInternalApi;
import software.amazon.awssdk.http.apache5.internal.net.InputShutdownCheckingSslSocket;
import software.amazon.awssdk.http.apache5.internal.net.SdkSocket;
import software.amazon.awssdk.http.apache5.internal.net.SdkSslSocket;
import software.amazon.awssdk.utils.Logger;

@SdkInternalApi
Expand Down Expand Up @@ -62,9 +60,6 @@ public Socket connectSocket(TimeValue connectTimeout,
log.trace(() -> String.format("Connecting to %s:%s", remoteAddress.getAddress(), remoteAddress.getPort()));

Socket connectSocket = super.connectSocket(connectTimeout, socket, host, remoteAddress, localAddress, context);
if (connectSocket instanceof SSLSocket) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

we test this with Apache5ClientTlsHalfCloseTest so that functionality is same

return new InputShutdownCheckingSslSocket(new SdkSslSocket((SSLSocket) connectSocket));
}
return new SdkSocket(connectSocket);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ private void addRequestConfig(HttpUriRequestBase base,
.setConnectionRequestTimeout(connectAcquireTimeout, TimeUnit.MILLISECONDS)
.setConnectTimeout(connectTimeout, TimeUnit.MILLISECONDS)
.setResponseTimeout(saturatedCast(requestConfig.socketTimeout().toMillis()), TimeUnit.MILLISECONDS);
// TODO as part of removed API : .setLocalAddress(requestConfig.localAddress());

/*
* Enable 100-continue support for PUT operations, since this is
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@
import java.io.IOException;
import java.io.UncheckedIOException;
import org.apache.hc.client5.http.auth.AuthCache;
import org.apache.hc.client5.http.auth.AuthScope;
import org.apache.hc.client5.http.auth.Credentials;
import org.apache.hc.client5.http.auth.CredentialsProvider;
import org.apache.hc.client5.http.auth.NTCredentials;
import org.apache.hc.client5.http.config.RequestConfig;
import org.apache.hc.client5.http.impl.auth.BasicAuthCache;
import org.apache.hc.client5.http.impl.auth.BasicCredentialsProvider;
Expand All @@ -37,8 +40,7 @@ private Apache5Utils() {
}

/**
* Utility function for creating a new BufferedEntity and wrapping any errors
* as a SdkClientException.
* Utility function for creating a new BufferedEntity and wrapping any errors as a SdkClientException.
*
* @param entity The HTTP entity to wrap with a buffered HTTP entity.
* @return A new BufferedHttpEntity wrapping the specified entity.
Expand Down Expand Up @@ -69,27 +71,29 @@ public static HttpClientContext newClientContext(ProxyConfiguration proxyConfigu
*/
public static CredentialsProvider newProxyCredentialsProvider(ProxyConfiguration proxyConfiguration) {
BasicCredentialsProvider provider = new BasicCredentialsProvider();
// TODO : NTCredentials is deprecated.
// provider.setCredentials(newAuthScope(proxyConfiguration), newNtCredentials(proxyConfiguration));
provider.setCredentials(newAuthScope(proxyConfiguration), newNtCredentials(proxyConfiguration));
return provider;
}

// /**
// * Returns a new instance of NTCredentials used for proxy authentication.
// */
// private static Credentials newNtCredentials(ProxyConfiguration proxyConfiguration) {
// return new NTCredentials(proxyConfiguration.username(),
// proxyConfiguration.password(),
// proxyConfiguration.ntlmWorkstation(),
// proxyConfiguration.ntlmDomain());
// }
/**
* Returns a new instance of NTCredentials used for proxy authentication.
*/
private static Credentials newNtCredentials(ProxyConfiguration proxyConfiguration) {
return new NTCredentials(
proxyConfiguration.username(),
proxyConfiguration.password().toCharArray(),
proxyConfiguration.ntlmWorkstation(),
proxyConfiguration.ntlmDomain()
);
}

/**
* Returns a new instance of AuthScope used for proxy authentication.
*/
private static AuthScope newAuthScope(ProxyConfiguration proxyConfiguration) {
return new AuthScope(proxyConfiguration.host(), proxyConfiguration.port());
}

// /**
// * Returns a new instance of AuthScope used for proxy authentication.
// */
// private static AuthScope newAuthScope(ProxyConfiguration proxyConfiguration) {
// return new AuthScope(proxyConfiguration.host(), proxyConfiguration.port());
// }

private static void addPreemptiveAuthenticationProxy(HttpClientContext clientContext,
ProxyConfiguration proxyConfiguration) {
Expand All @@ -107,5 +111,4 @@ private static void addPreemptiveAuthenticationProxy(HttpClientContext clientCon
clientContext.setAuthCache(authCache);
}
}

}
Loading