Fix typo method and class. Deprecate the old ones.

This commit is contained in:
Arturo Bernal 2021-11-11 14:11:24 +01:00 committed by Oleg Kalnichevski
parent 0e8adf79dc
commit 4d0caa4f42
12 changed files with 117 additions and 37 deletions

View File

@ -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;

View File

@ -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

View File

@ -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) {

View File

@ -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;
}

View File

@ -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,

View File

@ -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);
}

View File

@ -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);

View File

@ -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);

View File

@ -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;
}

View File

@ -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;
}
}
}

View File

@ -0,0 +1,72 @@
/*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License 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.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.hc.client5.http.async.methods;
import org.apache.hc.core5.concurrent.FutureCallback;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* @since 5.2
*/
public class IgnoreCompleteExceptionFutureCallback<T> implements FutureCallback<T> {
private final FutureCallback<T> callback;
private static final Logger LOG = LoggerFactory.getLogger(IgnoreCompleteExceptionFutureCallback.class);
public IgnoreCompleteExceptionFutureCallback(final FutureCallback<T> callback) {
super();
this.callback = callback;
}
@Override
public void completed(final T result) {
if (callback != null) {
try {
callback.completed(result);
} catch (final Exception ex) {
LOG.error(ex.getMessage(), ex);
}
}
}
@Override
public void failed(final Exception ex) {
if (callback != null) {
callback.failed(ex);
}
}
@Override
public void cancelled() {
if (callback != null) {
callback.cancelled();
}
}
}

View File

@ -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();
}
}