Skip to content

Commit 69b8679

Browse files
chore: remove legacy apache http from core (#2014)
The Android SDK uses HttpURLConnection as its HTTP runtime. aws-android-sdk-core contains dead code that references the legacy Apache HTTP Client used by the V1 Java SDK, from which this codebase originates. The Apache HTTP client has considerable baggage on the Android platform, and can cause runtime failures. In an effort to fully remove it from the codebase, it is being removed from core. As of this commit, Apache Logging is still a compile-time dependency in core. If it is provided at runtime, it will be used. Otherwise, the SDK will fallback to logging against the Android Log utility. This behavior is discussed here: #476
1 parent 9e43f1e commit 69b8679

26 files changed

+13
-1903
lines changed

aws-android-sdk-core/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ apply plugin: 'com.android.library'
22

33
android {
44
compileSdkVersion 28
5-
useLibrary 'org.apache.http.legacy'
65

76
defaultConfig {
87
minSdkVersion 9
@@ -16,6 +15,7 @@ android {
1615

1716
dependencies {
1817
api 'com.google.code.gson:gson:2.8.6'
18+
compileOnly 'commons-logging:commons-logging:1.2'
1919
implementation 'androidx.annotation:annotation:1.1.0'
2020

2121
testImplementation 'joda-time:joda-time:2.8.1'
@@ -24,6 +24,6 @@ dependencies {
2424
testImplementation 'org.easymock:easymock:3.1'
2525
testImplementation 'org.robolectric:robolectric:4.3.1'
2626
testImplementation 'xerces:xercesImpl:2.12.0'
27-
testRuntimeOnly 'org.apache.httpcomponents:httpclient:4.5.12'
27+
testRuntimeOnly 'commons-logging:commons-logging:1.2'
2828
}
2929

aws-android-sdk-core/pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@
2323
<artifactId>annotation</artifactId>
2424
<version>1.1.0</version>
2525
</dependency>
26+
<dependency>
27+
<groupId>commons-logging</groupId>
28+
<artifactId>commons-logging</artifactId>
29+
<version>1.2</version>
30+
<scope>provided</scope>
31+
</dependency>
2632
<dependency>
2733
<groupId>joda-time</groupId>
2834
<artifactId>joda-time</artifactId>

aws-android-sdk-core/src/main/java/com/amazonaws/ClientConfiguration.java

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
package com.amazonaws;
1717

18-
import com.amazonaws.http.IdleConnectionReaper;
1918
import com.amazonaws.retry.PredefinedRetryPolicies;
2019
import com.amazonaws.retry.RetryPolicy;
2120
import com.amazonaws.util.VersionInfoUtils;
@@ -57,14 +56,6 @@ public class ClientConfiguration {
5756
*/
5857
public static final RetryPolicy DEFAULT_RETRY_POLICY = PredefinedRetryPolicies.DEFAULT;
5958

60-
/**
61-
* The default on whether to use the {@link IdleConnectionReaper} to manage
62-
* stale connections
63-
*
64-
* @see IdleConnectionReaper
65-
*/
66-
public static final boolean DEFAULT_USE_REAPER = true;
67-
6859
/** The HTTP user agent header passed with all HTTP requests. */
6960
private String userAgent = DEFAULT_USER_AGENT;
7061

@@ -152,14 +143,6 @@ public class ClientConfiguration {
152143
*/
153144
private int socketReceiveBufferSizeHint = 0;
154145

155-
/**
156-
* Optional whether to use the {@link IdleConnectionReaper} to manage stale
157-
* connections. A reason for not running the {@link IdleConnectionReaper}
158-
* can be if running in an environment where the modifyThread and
159-
* modifyThreadGroup permissions are not allowed.
160-
*/
161-
private boolean useReaper = DEFAULT_USE_REAPER;
162-
163146
/**
164147
* Optional override to control which signature algorithm should be used to
165148
* sign requests to the service. If not explicitly set, the client will
@@ -210,7 +193,6 @@ public ClientConfiguration(ClientConfiguration other) {
210193
this.preemptiveBasicProxyAuth = other.preemptiveBasicProxyAuth;
211194
this.socketTimeout = other.socketTimeout;
212195
this.userAgent = other.userAgent;
213-
this.useReaper = other.useReaper;
214196
this.socketReceiveBufferSizeHint = other.socketReceiveBufferSizeHint;
215197
this.socketSendBufferSizeHint = other.socketSendBufferSizeHint;
216198
this.signerOverride = other.signerOverride;
@@ -752,40 +734,6 @@ public ClientConfiguration withConnectionTimeout(int connectionTimeout) {
752734
return this;
753735
}
754736

755-
/**
756-
* Checks if the {@link IdleConnectionReaper} is to be started
757-
*
758-
* @return if the {@link IdleConnectionReaper} is to be started
759-
*/
760-
public boolean useReaper() {
761-
return useReaper;
762-
}
763-
764-
/**
765-
* Sets whether the {@link IdleConnectionReaper} is to be started as a
766-
* daemon thread
767-
*
768-
* @param use whether the {@link IdleConnectionReaper} is to be started as a
769-
* daemon thread
770-
* @see IdleConnectionReaper
771-
*/
772-
public void setUseReaper(boolean use) {
773-
this.useReaper = use;
774-
}
775-
776-
/**
777-
* Sets whether the {@link IdleConnectionReaper} is to be started as a
778-
* daemon thread
779-
*
780-
* @param use the {@link IdleConnectionReaper} is to be started as a daemon
781-
* thread
782-
* @return The updated ClientConfiguration object.
783-
*/
784-
public ClientConfiguration withReaper(boolean use) {
785-
setUseReaper(use);
786-
return this;
787-
}
788-
789737
/**
790738
* Returns the optional size hints (in bytes) for the low level TCP send and
791739
* receive buffers. This is an advanced option for advanced users who want

aws-android-sdk-core/src/main/java/com/amazonaws/http/ApacheHttpClient.java

Lines changed: 0 additions & 146 deletions
This file was deleted.

aws-android-sdk-core/src/main/java/com/amazonaws/http/ConnectionManagerFactory.java

Lines changed: 0 additions & 58 deletions
This file was deleted.

aws-android-sdk-core/src/main/java/com/amazonaws/http/HttpClient.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717

1818
import com.amazonaws.AmazonWebServiceRequest;
1919

20-
import org.apache.http.conn.ssl.BrowserCompatHostnameVerifier;
21-
2220
import java.io.IOException;
2321

2422
/**
@@ -31,9 +29,6 @@
3129
* If modified, the request is likely to be rejected by AWS service.</li>
3230
* <li>Disable retry logic and redirect which are handled by the service client
3331
* itself.</li>
34-
* <li>Enable {@link BrowserCompatHostnameVerifier} so that a wildcard (such as
35-
* "*.amazonaws.com") matches all subdomains, including "a.b.amazonaws.com".
36-
* This is needed for S3 virtual hosting. See <a
3732
* href="http://docs.aws.amazon.com/AmazonS3/latest/dev/VirtualHosting.html"
3833
* >Virtual Hosting of Buckets</a> for more details.</li>
3934
* <li>Beware of the Expect 100-continue header. Currently it's only used in <a

0 commit comments

Comments
 (0)