You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2021/11/12 21:21:12 UTC
[httpcomponents-client] 02/02: Fix typo method and class. Deprecate
the old ones.
This is an automated email from the ASF dual-hosted git repository.
olegk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/httpcomponents-client.git
commit 4d0caa4f423aadfb0fabc87c11a9962f5c7e4d7a
Author: Arturo Bernal <ar...@gmail.com>
AuthorDate: Thu Nov 11 14:11:24 2021 +0100
Fix typo method and class. Deprecate the old ones.
---
.../client5/http/impl/cache/AsyncCachingExec.java | 2 +-
.../http/impl/cache/BasicHttpAsyncCache.java | 2 +-
.../hc/client5/http/impl/cache/BasicHttpCache.java | 2 +-
.../http/impl/cache/CacheInvalidatorBase.java | 2 +-
.../http/impl/cache/CacheUpdateHandler.java | 2 +-
.../hc/client5/http/impl/cache/CachingExec.java | 2 +-
.../client5/http/impl/cache/CachingExecBase.java | 5 +++-
.../impl/cache/DefaultAsyncCacheInvalidator.java | 8 +++---
.../http/impl/cache/DefaultCacheInvalidator.java | 8 +++---
.../client5/http/impl/cache/HttpCacheSupport.java | 17 ++++++++++++
... => IgnoreCompleteExceptionFutureCallback.java} | 9 ++++--
.../IgnoreCompleteExceptonFutureCallback.java | 32 +++++++---------------
12 files changed, 51 insertions(+), 40 deletions(-)
diff --git a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/AsyncCachingExec.java b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/AsyncCachingExec.java
index bbbd75c..6cc9832 100644
--- a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/AsyncCachingExec.java
+++ b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/AsyncCachingExec.java
@@ -231,7 +231,7 @@ class AsyncCachingExec extends CachingExecBase implements AsyncExecChainHandler
return;
}
- final SimpleHttpResponse fatalErrorResponse = getFatallyNoncompliantResponse(request, context);
+ final SimpleHttpResponse fatalErrorResponse = getFatallyNonCompliantResponse(request, context);
if (fatalErrorResponse != null) {
triggerResponse(fatalErrorResponse, scope, asyncExecCallback);
return;
diff --git a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/BasicHttpAsyncCache.java b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/BasicHttpAsyncCache.java
index e3bf75b..508c814 100644
--- a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/BasicHttpAsyncCache.java
+++ b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/BasicHttpAsyncCache.java
@@ -412,7 +412,7 @@ class BasicHttpAsyncCache implements HttpAsyncCache {
}
final String cacheKey = cacheKeyGenerator.generateKey(host, request);
try {
- final HttpCacheEntry entry = cacheUpdateHandler.createtCacheEntry(request, originResponse, content, requestSent, responseReceived);
+ final HttpCacheEntry entry = cacheUpdateHandler.createCacheEntry(request, originResponse, content, requestSent, responseReceived);
return storeInCache(cacheKey, host, request, entry, new FutureCallback<Boolean>() {
@Override
diff --git a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/BasicHttpCache.java b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/BasicHttpCache.java
index 70e5272..e6a7c1d 100644
--- a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/BasicHttpCache.java
+++ b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/BasicHttpCache.java
@@ -270,7 +270,7 @@ class BasicHttpCache implements HttpCache {
}
final String cacheKey = cacheKeyGenerator.generateKey(host, request);
try {
- final HttpCacheEntry entry = cacheUpdateHandler.createtCacheEntry(request, originResponse, content, requestSent, responseReceived);
+ final HttpCacheEntry entry = cacheUpdateHandler.createCacheEntry(request, originResponse, content, requestSent, responseReceived);
storeInCache(cacheKey, host, request, entry);
return entry;
} catch (final ResourceIOException ex) {
diff --git a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CacheInvalidatorBase.java b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CacheInvalidatorBase.java
index feaf95e..e7a9c66 100644
--- a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CacheInvalidatorBase.java
+++ b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CacheInvalidatorBase.java
@@ -68,7 +68,7 @@ class CacheInvalidatorBase {
if (h == null) {
return null;
}
- final URI locationUri = HttpCacheSupport.normalizeQuetly(h.getValue());
+ final URI locationUri = HttpCacheSupport.normalizeQuietly(h.getValue());
if (locationUri == null) {
return requestUri;
}
diff --git a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CacheUpdateHandler.java b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CacheUpdateHandler.java
index 7416766..bdb0d32 100644
--- a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CacheUpdateHandler.java
+++ b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CacheUpdateHandler.java
@@ -65,7 +65,7 @@ class CacheUpdateHandler {
/**
* Creates a cache entry for the given request, origin response message and response content.
*/
- public HttpCacheEntry createtCacheEntry(
+ public HttpCacheEntry createCacheEntry(
final HttpRequest request,
final HttpResponse originResponse,
final ByteArrayBuffer content,
diff --git a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CachingExec.java b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CachingExec.java
index 1272401..f72ebeb 100644
--- a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CachingExec.java
+++ b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CachingExec.java
@@ -178,7 +178,7 @@ class CachingExec extends CachingExecBase implements ExecChainHandler {
return new BasicClassicHttpResponse(HttpStatus.SC_NOT_IMPLEMENTED);
}
- final SimpleHttpResponse fatalErrorResponse = getFatallyNoncompliantResponse(request, context);
+ final SimpleHttpResponse fatalErrorResponse = getFatallyNonCompliantResponse(request, context);
if (fatalErrorResponse != null) {
return convert(fatalErrorResponse, scope);
}
diff --git a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CachingExecBase.java b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CachingExecBase.java
index 3a7a462..cec75bf 100644
--- a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CachingExecBase.java
+++ b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CachingExecBase.java
@@ -139,7 +139,10 @@ public class CachingExecBase {
return cacheUpdates.get();
}
- SimpleHttpResponse getFatallyNoncompliantResponse(
+ /**
+ * @since 5.2
+ */
+ SimpleHttpResponse getFatallyNonCompliantResponse(
final HttpRequest request,
final HttpContext context) {
final List<RequestProtocolError> fatalError = requestCompliance.requestIsFatallyNonCompliant(request);
diff --git a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/DefaultAsyncCacheInvalidator.java b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/DefaultAsyncCacheInvalidator.java
index 77b720b..226c644 100644
--- a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/DefaultAsyncCacheInvalidator.java
+++ b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/DefaultAsyncCacheInvalidator.java
@@ -100,7 +100,7 @@ public class DefaultAsyncCacheInvalidator extends CacheInvalidatorBase implement
final HttpAsyncCacheStorage storage,
final FutureCallback<Boolean> callback) {
final String s = HttpCacheSupport.getRequestUri(request, host);
- final URI uri = HttpCacheSupport.normalizeQuetly(s);
+ final URI uri = HttpCacheSupport.normalizeQuietly(s);
final String cacheKey = uri != null ? cacheKeyResolver.resolve(uri) : s;
return storage.getEntry(cacheKey, new FutureCallback<HttpCacheEntry>() {
@@ -122,7 +122,7 @@ public class DefaultAsyncCacheInvalidator extends CacheInvalidatorBase implement
}
final Header clHdr = request.getFirstHeader("Content-Location");
if (clHdr != null) {
- final URI contentLocation = HttpCacheSupport.normalizeQuetly(clHdr.getValue());
+ final URI contentLocation = HttpCacheSupport.normalizeQuietly(clHdr.getValue());
if (contentLocation != null) {
if (!flushAbsoluteUriFromSameHost(uri, contentLocation, cacheKeyResolver, storage)) {
flushRelativeUriFromSameHost(uri, contentLocation, cacheKeyResolver, storage);
@@ -131,7 +131,7 @@ public class DefaultAsyncCacheInvalidator extends CacheInvalidatorBase implement
}
final Header lHdr = request.getFirstHeader("Location");
if (lHdr != null) {
- final URI location = HttpCacheSupport.normalizeQuetly(lHdr.getValue());
+ final URI location = HttpCacheSupport.normalizeQuietly(lHdr.getValue());
if (location != null) {
flushAbsoluteUriFromSameHost(uri, location, cacheKeyResolver, storage);
}
@@ -189,7 +189,7 @@ public class DefaultAsyncCacheInvalidator extends CacheInvalidatorBase implement
final int status = response.getCode();
if (status >= HttpStatus.SC_SUCCESS && status < HttpStatus.SC_REDIRECTION) {
final String s = HttpCacheSupport.getRequestUri(request, host);
- final URI requestUri = HttpCacheSupport.normalizeQuetly(s);
+ final URI requestUri = HttpCacheSupport.normalizeQuietly(s);
if (requestUri != null) {
final List<String> cacheKeys = new ArrayList<>(2);
final URI contentLocation = getContentLocationURI(requestUri, response);
diff --git a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/DefaultCacheInvalidator.java b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/DefaultCacheInvalidator.java
index debc1a5..b57bba9 100644
--- a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/DefaultCacheInvalidator.java
+++ b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/DefaultCacheInvalidator.java
@@ -86,7 +86,7 @@ public class DefaultCacheInvalidator extends CacheInvalidatorBase implements Htt
final Resolver<URI, String> cacheKeyResolver,
final HttpCacheStorage storage) {
final String s = HttpCacheSupport.getRequestUri(request, host);
- final URI uri = HttpCacheSupport.normalizeQuetly(s);
+ final URI uri = HttpCacheSupport.normalizeQuietly(s);
final String cacheKey = uri != null ? cacheKeyResolver.resolve(uri) : s;
final HttpCacheEntry parent = getEntry(storage, cacheKey);
@@ -106,7 +106,7 @@ public class DefaultCacheInvalidator extends CacheInvalidatorBase implements Htt
}
final Header clHdr = request.getFirstHeader("Content-Location");
if (clHdr != null) {
- final URI contentLocation = HttpCacheSupport.normalizeQuetly(clHdr.getValue());
+ final URI contentLocation = HttpCacheSupport.normalizeQuietly(clHdr.getValue());
if (contentLocation != null) {
if (!flushAbsoluteUriFromSameHost(uri, contentLocation, cacheKeyResolver, storage)) {
flushRelativeUriFromSameHost(uri, contentLocation, cacheKeyResolver, storage);
@@ -115,7 +115,7 @@ public class DefaultCacheInvalidator extends CacheInvalidatorBase implements Htt
}
final Header lHdr = request.getFirstHeader("Location");
if (lHdr != null) {
- final URI location = HttpCacheSupport.normalizeQuetly(lHdr.getValue());
+ final URI location = HttpCacheSupport.normalizeQuietly(lHdr.getValue());
if (location != null) {
flushAbsoluteUriFromSameHost(uri, location, cacheKeyResolver, storage);
}
@@ -159,7 +159,7 @@ public class DefaultCacheInvalidator extends CacheInvalidatorBase implements Htt
return;
}
final String s = HttpCacheSupport.getRequestUri(request, host);
- final URI uri = HttpCacheSupport.normalizeQuetly(s);
+ final URI uri = HttpCacheSupport.normalizeQuietly(s);
if (uri == null) {
return;
}
diff --git a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/HttpCacheSupport.java b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/HttpCacheSupport.java
index 1233062..67e03f1 100644
--- a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/HttpCacheSupport.java
+++ b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/HttpCacheSupport.java
@@ -123,7 +123,9 @@ public final class HttpCacheSupport {
/**
* Lenient URI parser that normalizes valid {@link URI}s and returns {@code null} for malformed URIs.
+ * @deprecated Use {@link #normalizeQuietly(String)}
*/
+ @Deprecated
public static URI normalizeQuetly(final String requestUri) {
if (requestUri == null) {
return null;
@@ -135,4 +137,19 @@ public final class HttpCacheSupport {
}
}
+ /**
+ * Lenient URI parser that normalizes valid {@link URI}s and returns {@code null} for malformed URIs.
+ * @since 5.2
+ */
+ public static URI normalizeQuietly(final String requestUri) {
+ if (requestUri == null) {
+ return null;
+ }
+ try {
+ return normalize(new URI(requestUri));
+ } catch (final URISyntaxException ex) {
+ return null;
+ }
+ }
+
}
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/IgnoreCompleteExceptonFutureCallback.java b/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/IgnoreCompleteExceptionFutureCallback.java
similarity index 89%
copy from httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/IgnoreCompleteExceptonFutureCallback.java
copy to httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/IgnoreCompleteExceptionFutureCallback.java
index 3d108e1..0191294 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/IgnoreCompleteExceptonFutureCallback.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/IgnoreCompleteExceptionFutureCallback.java
@@ -30,13 +30,16 @@ import org.apache.hc.core5.concurrent.FutureCallback;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class IgnoreCompleteExceptonFutureCallback<T> implements FutureCallback<T> {
+/**
+ * @since 5.2
+ */
+public class IgnoreCompleteExceptionFutureCallback<T> implements FutureCallback<T> {
private final FutureCallback<T> callback;
- private static final Logger LOG = LoggerFactory.getLogger(IgnoreCompleteExceptonFutureCallback.class);
+ private static final Logger LOG = LoggerFactory.getLogger(IgnoreCompleteExceptionFutureCallback.class);
- public IgnoreCompleteExceptonFutureCallback(final FutureCallback<T> callback) {
+ public IgnoreCompleteExceptionFutureCallback(final FutureCallback<T> callback) {
super();
this.callback = callback;
}
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/IgnoreCompleteExceptonFutureCallback.java b/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/IgnoreCompleteExceptonFutureCallback.java
index 3d108e1..d693807 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/IgnoreCompleteExceptonFutureCallback.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/IgnoreCompleteExceptonFutureCallback.java
@@ -27,43 +27,31 @@
package org.apache.hc.client5.http.async.methods;
import org.apache.hc.core5.concurrent.FutureCallback;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-public class IgnoreCompleteExceptonFutureCallback<T> implements FutureCallback<T> {
-
- private final FutureCallback<T> callback;
-
- private static final Logger LOG = LoggerFactory.getLogger(IgnoreCompleteExceptonFutureCallback.class);
+/**
+ * @deprecated Use {@link IgnoreCompleteExceptionFutureCallback}
+ * @since 5.2
+ */
+@Deprecated
+public class IgnoreCompleteExceptonFutureCallback<T> extends IgnoreCompleteExceptionFutureCallback<T> implements FutureCallback<T> {
public IgnoreCompleteExceptonFutureCallback(final FutureCallback<T> callback) {
- super();
- this.callback = callback;
+ super(callback);
}
@Override
public void completed(final T result) {
- if (callback != null) {
- try {
- callback.completed(result);
- } catch (final Exception ex) {
- LOG.error(ex.getMessage(), ex);
- }
- }
+ super.completed(result);
}
@Override
public void failed(final Exception ex) {
- if (callback != null) {
- callback.failed(ex);
- }
+ super.failed(ex);
}
@Override
public void cancelled() {
- if (callback != null) {
- callback.cancelled();
- }
+ super.cancelled();
}
}