private static boolean shouldRetry( final Optional<Integer> readTimeoutMs, final ProcessingException e ) { return readTimeoutMs.map(timeout -> timeout < MAX_TIMEOUT).orElse(false) && e.getCause() instanceof SocketTimeoutException; }
@Override public void failed(final ProcessingException error) { try { if (error.getCause() instanceof WebApplicationException) { responseFuture.completeExceptionally(error.getCause()); } else if (!responseFuture.isCancelled()) { responseFuture.completeExceptionally(error); } } finally { callback.failed(error.getCause() instanceof CancellationException ? error.getCause() : error); } } };
@Override public void failed(final ProcessingException error) { try { if (error.getCause() instanceof WebApplicationException) { responseFuture.completeExceptionally(error.getCause()); } else if (!responseFuture.isCancelled()) { responseFuture.completeExceptionally(error); } } finally { callback.failed(error.getCause() instanceof CancellationException ? error.getCause() : error); } } };
@Override public RES_T exec(CMD_T command) { // this hack works because of ResponseStatusExceptionFilter try (CMD_T cmd = command) { try { return execute(cmd); } catch (ProcessingException e) { if (e.getCause() instanceof DockerException) { throw (DockerException) e.getCause(); } else { throw e; } } } }
@Override public void failed(final ProcessingException error) { try { if (error.getCause() instanceof WebApplicationException) { responseFuture.completeExceptionally(error.getCause()); } else if (!responseFuture.isCancelled()) { responseFuture.completeExceptionally(error); } } finally { callback.failed(error.getCause() instanceof CancellationException ? error.getCause() : error); } } };
public FormValidation doTestConnection(@QueryParameter String url, @QueryParameter String apiTokenId, @QueryParameter String clientBuilderId, @QueryParameter boolean ignoreCertificateErrors, @QueryParameter int connectionTimeout, @QueryParameter int readTimeout) { try { new GitLabConnection("", url, apiTokenId, clientBuilderId, ignoreCertificateErrors, connectionTimeout, readTimeout).getClient().getCurrentUser(); return FormValidation.ok(Messages.connection_success()); } catch (WebApplicationException e) { return FormValidation.error(Messages.connection_error(e.getMessage())); } catch (ProcessingException e) { return FormValidation.error(Messages.connection_error(e.getCause().getMessage())); } }
@Override public <T> T invoke(final GenericType<T> responseType) throws ProcessingException, WebApplicationException { if (responseType == null) { throw new IllegalArgumentException(LocalizationMessages.RESPONSE_TYPE_IS_NULL()); } final ClientRuntime runtime = request().getClientRuntime(); final RequestScope requestScope = runtime.getRequestScope(); //noinspection Duplicates return requestScope.runInScope(() -> { try { return translate(runtime.invoke(requestForCall(requestContext)), requestScope, responseType); } catch (final ProcessingException ex) { if (ex.getCause() instanceof WebApplicationException) { throw (WebApplicationException) ex.getCause(); } throw ex; } }); }
@Override public <T> T invoke(final GenericType<T> responseType) throws ProcessingException, WebApplicationException { if (responseType == null) { throw new IllegalArgumentException(LocalizationMessages.RESPONSE_TYPE_IS_NULL()); } final ClientRuntime runtime = request().getClientRuntime(); final RequestScope requestScope = runtime.getRequestScope(); //noinspection Duplicates return requestScope.runInScope(() -> { try { return translate(runtime.invoke(requestForCall(requestContext)), requestScope, responseType); } catch (final ProcessingException ex) { if (ex.getCause() instanceof WebApplicationException) { throw (WebApplicationException) ex.getCause(); } throw ex; } }); }
@Override public <T> T invoke(final Class<T> responseType) throws ProcessingException, WebApplicationException { if (responseType == null) { throw new IllegalArgumentException(LocalizationMessages.RESPONSE_TYPE_IS_NULL()); } final ClientRuntime runtime = request().getClientRuntime(); final RequestScope requestScope = runtime.getRequestScope(); //noinspection Duplicates return requestScope.runInScope(() -> { try { return translate(runtime.invoke(requestForCall(requestContext)), requestScope, responseType); } catch (final ProcessingException ex) { if (ex.getCause() instanceof WebApplicationException) { throw (WebApplicationException) ex.getCause(); } throw ex; } }); }
@Override public <T> T invoke(final Class<T> responseType) throws ProcessingException, WebApplicationException { if (responseType == null) { throw new IllegalArgumentException(LocalizationMessages.RESPONSE_TYPE_IS_NULL()); } final ClientRuntime runtime = request().getClientRuntime(); final RequestScope requestScope = runtime.getRequestScope(); //noinspection Duplicates return requestScope.runInScope(() -> { try { return translate(runtime.invoke(requestForCall(requestContext)), requestScope, responseType); } catch (final ProcessingException ex) { if (ex.getCause() instanceof WebApplicationException) { throw (WebApplicationException) ex.getCause(); } throw ex; } }); }
private <T> T translate(final ClientResponse response, final RequestScope scope, final GenericType<T> responseType) throws ProcessingException { if (responseType.getRawType() == Response.class) { //noinspection unchecked return (T) new InboundJaxrsResponse(response, scope); } if (response.getStatusInfo().getFamily() == Response.Status.Family.SUCCESSFUL) { try { return response.readEntity(responseType); } catch (final ProcessingException ex) { throw new ResponseProcessingException( new InboundJaxrsResponse(response, scope), ex.getCause() != null ? ex.getCause() : ex); } catch (final WebApplicationException ex) { throw new ResponseProcessingException(new InboundJaxrsResponse(response, scope), ex); } catch (final Exception ex) { throw new ResponseProcessingException(new InboundJaxrsResponse(response, scope), LocalizationMessages.UNEXPECTED_ERROR_RESPONSE_PROCESSING(), ex); } } else { throw convertToException(new InboundJaxrsResponse(response, scope)); } }
private <T> T translate(final ClientResponse response, final RequestScope scope, final GenericType<T> responseType) throws ProcessingException { if (responseType.getRawType() == Response.class) { //noinspection unchecked return (T) new InboundJaxrsResponse(response, scope); } if (response.getStatusInfo().getFamily() == Response.Status.Family.SUCCESSFUL) { try { return response.readEntity(responseType); } catch (final ProcessingException ex) { throw new ResponseProcessingException( new InboundJaxrsResponse(response, scope), ex.getCause() != null ? ex.getCause() : ex); } catch (final WebApplicationException ex) { throw new ResponseProcessingException(new InboundJaxrsResponse(response, scope), ex); } catch (final Exception ex) { throw new ResponseProcessingException(new InboundJaxrsResponse(response, scope), LocalizationMessages.UNEXPECTED_ERROR_RESPONSE_PROCESSING(), ex); } } else { throw convertToException(new InboundJaxrsResponse(response, scope)); } }
private <T> T translate(final ClientResponse response, final RequestScope scope, final Class<T> responseType) throws ProcessingException { if (responseType == Response.class) { return responseType.cast(new InboundJaxrsResponse(response, scope)); } if (response.getStatusInfo().getFamily() == Response.Status.Family.SUCCESSFUL) { try { return response.readEntity(responseType); } catch (final ProcessingException ex) { if (ex.getClass() == ProcessingException.class) { throw new ResponseProcessingException(new InboundJaxrsResponse(response, scope), ex.getCause()); } throw new ResponseProcessingException(new InboundJaxrsResponse(response, scope), ex); } catch (final WebApplicationException ex) { throw new ResponseProcessingException(new InboundJaxrsResponse(response, scope), ex); } catch (final Exception ex) { throw new ResponseProcessingException(new InboundJaxrsResponse(response, scope), LocalizationMessages.UNEXPECTED_ERROR_RESPONSE_PROCESSING(), ex); } } else { throw convertToException(new InboundJaxrsResponse(response, scope)); } }
private <T> T translate(final ClientResponse response, final RequestScope scope, final Class<T> responseType) throws ProcessingException { if (responseType == Response.class) { return responseType.cast(new InboundJaxrsResponse(response, scope)); } if (response.getStatusInfo().getFamily() == Response.Status.Family.SUCCESSFUL) { try { return response.readEntity(responseType); } catch (final ProcessingException ex) { if (ex.getClass() == ProcessingException.class) { throw new ResponseProcessingException(new InboundJaxrsResponse(response, scope), ex.getCause()); } throw new ResponseProcessingException(new InboundJaxrsResponse(response, scope), ex); } catch (final WebApplicationException ex) { throw new ResponseProcessingException(new InboundJaxrsResponse(response, scope), ex); } catch (final Exception ex) { throw new ResponseProcessingException(new InboundJaxrsResponse(response, scope), LocalizationMessages.UNEXPECTED_ERROR_RESPONSE_PROCESSING(), ex); } } else { throw convertToException(new InboundJaxrsResponse(response, scope)); } }