@Override public void handleException(Map<String, Object> ctx, final Throwable ex) { context = ctx; exception = ex; if (handler != null) { handler.failed(new ClientException(exception)); } done = true; synchronized (this) { notifyAll(); } }
@Override public boolean cancel(boolean mayInterruptIfRunning) { boolean result = super.cancel(mayInterruptIfRunning); if (result && handler != null) { handler.failed(new ClientException(new CancellationException())); } return result; }
protected static void reportInvalidResourceMethod(Method m, String name) { org.apache.cxf.common.i18n.Message errorMsg = new org.apache.cxf.common.i18n.Message(name, BUNDLE, m.getDeclaringClass().getName(), m.getName()); LOG.severe(errorMsg.toString()); throw new ClientException(errorMsg.toString()); }
public T get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { try { return getObject(callback.get(timeout, unit)[0]); } catch (InterruptedException ex) { if (callback.handler != null) { callback.handler.failed(new ClientException((InterruptedException)ex)); } throw ex; } }
public T get() throws InterruptedException, ExecutionException { try { return getObject(callback.get()[0]); } catch (InterruptedException ex) { if (callback.handler != null) { callback.handler.failed(new ClientException((InterruptedException)ex)); } throw ex; } } public T get(long timeout, TimeUnit unit) throws InterruptedException,
protected void waitForResponseCode(Exchange exchange) { synchronized (exchange) { if (getResponseCode(exchange) == null) { try { exchange.wait(cfg.getSynchronousTimeout()); } catch (InterruptedException ex) { // ignore } } else { return; } } if (getResponseCode(exchange) == null) { throw new ClientException("Response timeout"); } }
protected static void reportMessageHandlerProblem(String name, Class<?> cls, MediaType ct, Throwable ex, Response response) { org.apache.cxf.common.i18n.Message errorMsg = new org.apache.cxf.common.i18n.Message(name, BUNDLE, cls, JAXRSUtils.mediaTypeToString(ct)); LOG.severe(errorMsg.toString()); Throwable actualEx = ex instanceof Fault ? ((Fault)ex).getCause() : ex; throw new ClientException(errorMsg.toString(), actualEx); }
protected Response doResponse(Message m, Class<?> responseClass, Type outGenericType) { try { Object[] results = preProcessResult(m); if (results != null && results.length == 1) { return (Response)results[0]; } } catch (Exception ex) { throw ex instanceof WebApplicationException ? (WebApplicationException)ex : ex instanceof ClientException ? new ClientException(ex) : new RuntimeException(ex); } Response response = null; Object entity = null; try { response = handleResponse(m, responseClass, outGenericType); entity = response.getEntity(); return response; } catch (RuntimeException ex) { entity = ex; throw ex; } finally { completeExchange(entity, m.getExchange(), false); } }
} catch (Throwable ex) { throw (ex instanceof ClientException) ? (ClientException)ex : new ClientException(ex); } finally { ProviderFactory.getInstance(outMessage).clearThreadLocalProxies();
public void handleMessage(Message inMessage) throws Fault { ProviderFactory pf = ProviderFactory.getInstance(inMessage); if (pf == null) { return; } List<ProviderInfo<ClientResponseFilter>> filters = pf.getClientResponseFilters(); if (!filters.isEmpty()) { ClientRequestContext reqContext = new ClientRequestContextImpl(inMessage.getExchange().getOutMessage(), true); ClientResponseContext respContext = new ClientResponseContextImpl(getResponse(inMessage), inMessage); for (ProviderInfo<ClientResponseFilter> filter : filters) { InjectionUtils.injectContexts(filter.getProvider(), filter, inMessage); try { filter.getProvider().filter(reqContext, respContext); } catch (IOException ex) { throw new ClientException(ex); } } } }
protected void checkClientException(Message outMessage, Exception ex) throws Exception { Throwable actualEx = ex instanceof Fault ? ((Fault)ex).getCause() : ex; Integer responseCode = getResponseCode(outMessage.getExchange()); if (responseCode == null || actualEx instanceof IOException && outMessage.getExchange().get("client.redirect.exception") != null) { if (actualEx instanceof ClientException) { throw ex; } else if (actualEx != null) { throw new ClientException(actualEx); } else if (!outMessage.getExchange().isOneWay() || cfg.isResponseExpectedForOneway()) { waitForResponseCode(outMessage.getExchange()); } } }
? (WebApplicationException)ex : ex instanceof ClientException ? (ClientException)ex : new ClientException(ex); cb.handleException(message, t); return;
throw new ClientException(ex);