|
30 | 30 | import software.amazon.awssdk.annotations.SdkInternalApi;
|
31 | 31 | import software.amazon.awssdk.http.apache5.ProxyConfiguration;
|
32 | 32 | import software.amazon.awssdk.utils.Logger;
|
33 |
| -import software.amazon.awssdk.utils.ReflectionMethodInvoker; |
34 | 33 |
|
35 | 34 | @SdkInternalApi
|
36 | 35 | public final class Apache5Utils {
|
37 | 36 | private static final Logger logger = Logger.loggerFor(Apache5Utils.class);
|
38 |
| - private static final ReflectionMethodInvoker<RequestConfig.Builder, RequestConfig.Builder> NORMALIZE_URI_INVOKER; |
39 |
| - |
40 |
| - static { |
41 |
| - // Attempt to initialize the invoker once on class-load. If it fails, it will not be attempted again, but we'll |
42 |
| - // use that opportunity to log a warning. |
43 |
| - NORMALIZE_URI_INVOKER = |
44 |
| - new ReflectionMethodInvoker<>(RequestConfig.Builder.class, |
45 |
| - RequestConfig.Builder.class, |
46 |
| - "setNormalizeUri", |
47 |
| - boolean.class); |
48 |
| - |
49 |
| - try { |
50 |
| - NORMALIZE_URI_INVOKER.initialize(); |
51 |
| - } catch (NoSuchMethodException ignored) { |
52 |
| - noSuchMethodThrownByNormalizeUriInvoker(); |
53 |
| - } |
54 |
| - } |
55 | 37 |
|
56 | 38 | private Apache5Utils() {
|
57 | 39 | }
|
@@ -79,36 +61,11 @@ public static HttpClientContext newClientContext(ProxyConfiguration proxyConfigu
|
79 | 61 | addPreemptiveAuthenticationProxy(clientContext, proxyConfiguration);
|
80 | 62 |
|
81 | 63 | RequestConfig.Builder builder = RequestConfig.custom();
|
82 |
| - disableNormalizeUri(builder); |
83 |
| - |
84 | 64 | clientContext.setRequestConfig(builder.build());
|
85 | 65 | return clientContext;
|
86 | 66 |
|
87 | 67 | }
|
88 | 68 |
|
89 |
| - /** |
90 |
| - * From Apache v4.5.8, normalization should be disabled or AWS requests with special characters in URI path will fail |
91 |
| - * with Signature Errors. |
92 |
| - * <p> |
93 |
| - * setNormalizeUri is added only in 4.5.8, so customers using the latest version of SDK with old versions (4.5.6 or less) |
94 |
| - * of Apache httpclient will see NoSuchMethodError. Hence this method will suppress the error. |
95 |
| - * |
96 |
| - * Do not use Apache version 4.5.7 as it breaks URI paths with special characters and there is no option |
97 |
| - * to disable normalization. |
98 |
| - * </p> |
99 |
| - * |
100 |
| - * For more information, See https://github.com/aws/aws-sdk-java/issues/1919 |
101 |
| - */ |
102 |
| - public static void disableNormalizeUri(RequestConfig.Builder requestConfigBuilder) { |
103 |
| - // For efficiency, do not attempt to call the invoker again if it failed to initialize on class-load |
104 |
| - if (NORMALIZE_URI_INVOKER.isInitialized()) { |
105 |
| - try { |
106 |
| - NORMALIZE_URI_INVOKER.invoke(requestConfigBuilder, false); |
107 |
| - } catch (NoSuchMethodException ignored) { |
108 |
| - noSuchMethodThrownByNormalizeUriInvoker(); |
109 |
| - } |
110 |
| - } |
111 |
| - } |
112 | 69 |
|
113 | 70 | /**
|
114 | 71 | * Returns a new Credentials Provider for use with proxy authentication.
|
@@ -154,13 +111,4 @@ private static void addPreemptiveAuthenticationProxy(HttpClientContext clientCon
|
154 | 111 | }
|
155 | 112 | }
|
156 | 113 |
|
157 |
| - // Just log and then swallow the exception |
158 |
| - private static void noSuchMethodThrownByNormalizeUriInvoker() { |
159 |
| - // setNormalizeUri method was added in httpclient 4.5.8 |
160 |
| - logger.warn(() -> "NoSuchMethodException was thrown when disabling normalizeUri. This indicates you are using " |
161 |
| - + "an old version (< 4.5.8) of Apache http client. It is recommended to use http client " |
162 |
| - + "version >= 4.5.9 to avoid the breaking change introduced in apache client 4.5.7 and " |
163 |
| - + "the latency in exception handling. See https://github.com/aws/aws-sdk-java/issues/1919" |
164 |
| - + " for more information"); |
165 |
| - } |
166 | 114 | }
|
0 commit comments