use of javax.ws.rs.client.ResponseProcessingException in project so by onap.
the class RestClientTest method retryOnChunkedNetworkIssue.
@Test
public void retryOnChunkedNetworkIssue() throws Exception {
RestClient spy = buildSpy();
doThrow(new ResponseProcessingException(null, "something something", new SSLException("wow"))).when(spy).buildRequest(any(String.class), ArgumentMatchers.isNull());
try {
spy.get();
} catch (Exception e) {
// ignore this exception for this test
}
verify(spy, times(3)).buildRequest(any(String.class), ArgumentMatchers.isNull());
}
use of javax.ws.rs.client.ResponseProcessingException in project oci-java-sdk by oracle.
the class RestClient method convertToBmcException.
/**
* Wraps a ProcessingException as a BmcException.
*
* @param target
* The target being called.
* @param e
* The processing exception.
* @return A new BmcException.
*/
private static BmcException convertToBmcException(WebTarget target, ProcessingException e, InvocationInformation info) {
if (e instanceof ResponseProcessingException) {
final ResponseProcessingException responseProcessingException = (ResponseProcessingException) e;
final Response response = responseProcessingException.getResponse();
if (response != null) {
final String statusMessage = response.getStatusInfo() != null ? response.getStatusInfo().getReasonPhrase() : "";
return new BmcException(response.getStatus(), statusMessage, e.getMessage(), info.getRequestId(), e);
}
}
Throwable t = Throwables.getRootCause(e);
if (t instanceof InterruptedIOException) {
return new BmcException(true, "Timed out while communicating to: " + getUriSafe(target), e, info.getRequestId());
}
return new BmcException(false, "Processing exception while communicating to: " + getUriSafe(target), e, info.getRequestId());
}
use of javax.ws.rs.client.ResponseProcessingException in project tomee by apache.
the class ResponseImpl method close.
@Override
public void close() throws ProcessingException {
if (!entityClosed) {
if (!entityBufferred && entity instanceof InputStream) {
try {
((InputStream) entity).close();
} catch (IOException ex) {
throw new ResponseProcessingException(this, ex);
}
}
entity = null;
entityClosed = true;
}
}
use of javax.ws.rs.client.ResponseProcessingException in project tomee by apache.
the class ResponseImpl method bufferEntity.
@Override
public boolean bufferEntity() throws ProcessingException {
checkEntityIsClosed();
if (!entityBufferred && entity instanceof InputStream) {
try {
InputStream oldEntity = (InputStream) entity;
entity = IOUtils.loadIntoBAIS(oldEntity);
oldEntity.close();
entityBufferred = true;
} catch (IOException ex) {
throw new ResponseProcessingException(this, ex);
}
}
return entityBufferred;
}
use of javax.ws.rs.client.ResponseProcessingException in project cxf by apache.
the class AbstractClient method checkClientException.
protected void checkClientException(Message outMessage, Exception ex) throws Exception {
Throwable actualEx = ex instanceof Fault ? ((Fault) ex).getCause() : ex;
Exchange exchange = outMessage.getExchange();
Integer responseCode = getResponseCode(exchange);
if (actualEx instanceof ResponseProcessingException) {
throw (ResponseProcessingException) actualEx;
} else if (responseCode == null || responseCode < 300 && !(actualEx instanceof IOException) || actualEx instanceof IOException && exchange.get("client.redirect.exception") != null) {
if (actualEx instanceof ProcessingException) {
throw (RuntimeException) actualEx;
} else if (actualEx != null) {
Object useProcExProp = exchange.get("wrap.in.processing.exception");
if (actualEx instanceof RuntimeException && useProcExProp != null && PropertyUtils.isFalse(useProcExProp)) {
throw (Exception) actualEx;
}
throw new ProcessingException(actualEx);
} else if (!exchange.isOneWay() || cfg.isResponseExpectedForOneway()) {
waitForResponseCode(exchange);
}
}
}
Aggregations