|
|
|
@ -136,18 +136,29 @@ public class DefaultResponseErrorHandler implements ResponseErrorHandler { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void handleError(URI url, HttpMethod method, ClientHttpResponse response) throws IOException { |
|
|
|
public void handleError(URI url, HttpMethod method, ClientHttpResponse response) throws IOException { |
|
|
|
handleError(response); |
|
|
|
|
|
|
|
|
|
|
|
// For backwards compatibility try handle(response) first
|
|
|
|
|
|
|
|
HandleErrorResponseDecorator decorator = new HandleErrorResponseDecorator(response); |
|
|
|
|
|
|
|
handleError(decorator); |
|
|
|
|
|
|
|
if (decorator.isHandled()) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
handleError(response, response.getStatusCode(), url, method); |
|
|
|
handleError(response, response.getStatusCode(), url, method); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* {@inheritDoc} |
|
|
|
|
|
|
|
* <p>As of 6.2.1 this method is a no-op unless overridden. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@SuppressWarnings("removal") |
|
|
|
@SuppressWarnings("removal") |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void handleError(ClientHttpResponse response) throws IOException { |
|
|
|
public void handleError(ClientHttpResponse response) throws IOException { |
|
|
|
// no-op, but here for backwards compatibility
|
|
|
|
|
|
|
|
|
|
|
|
// Called via handleError(url, method, response)
|
|
|
|
|
|
|
|
if (response instanceof HandleErrorResponseDecorator decorator) { |
|
|
|
|
|
|
|
decorator.setNotHandled(); |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Called directly, so do handle
|
|
|
|
|
|
|
|
handleError(response, response.getStatusCode(), null, null); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
@ -277,4 +288,22 @@ public class DefaultResponseErrorHandler implements ResponseErrorHandler { |
|
|
|
}; |
|
|
|
}; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static class HandleErrorResponseDecorator extends ClientHttpResponseDecorator { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private boolean handled = true; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public HandleErrorResponseDecorator(ClientHttpResponse delegate) { |
|
|
|
|
|
|
|
super(delegate); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void setNotHandled() { |
|
|
|
|
|
|
|
this.handled = false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public boolean isHandled() { |
|
|
|
|
|
|
|
return this.handled; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|