org.springframework.web.client.DefaultResponseErrorHandler Java Examples
The following examples show how to use
org.springframework.web.client.DefaultResponseErrorHandler.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RemoteTokenServices.java From MaxKey with Apache License 2.0 | 5 votes |
public RemoteTokenServices() { restTemplate = new RestTemplate(); ((RestTemplate) restTemplate).setErrorHandler(new DefaultResponseErrorHandler() { @Override // Ignore 400 public void handleError(ClientHttpResponse response) throws IOException { if (response.getRawStatusCode() != 400) { super.handleError(response); } } }); }
Example #2
Source File: HttpCodeTest.java From jsonrpc4j with MIT License | 5 votes |
@Test public void httpCustomStatus() throws MalformedURLException { expectedEx.expectMessage(equalTo("Server Error")); expectedEx.expect(JsonRpcClientException.class); RestTemplate restTemplate = new RestTemplate(); JsonRpcRestClient client = getClient(JettyServer.SERVLET, restTemplate); // Overwrite error handler for error check. restTemplate.setErrorHandler(new DefaultResponseErrorHandler()); FakeServiceInterface service = ProxyUtil.createClientProxy(FakeServiceInterface.class, client); service.throwSomeException("function error"); }
Example #3
Source File: FacebookTokenServices.java From geowave with Apache License 2.0 | 5 votes |
public FacebookTokenServices() { restTemplate = new RestTemplate(); ((RestTemplate) restTemplate).setErrorHandler(new DefaultResponseErrorHandler() { @Override // Ignore 400 public void handleError(final ClientHttpResponse response) throws IOException { if (response.getRawStatusCode() != 400) { super.handleError(response); } } }); }
Example #4
Source File: BaseRepositoryTest.java From kurento-java with Apache License 2.0 | 5 votes |
protected RestTemplate getRestTemplate() { RestTemplate restTemplate = new RestTemplate(); restTemplate.setErrorHandler(new DefaultResponseErrorHandler() { @Override public void handleError(ClientHttpResponse response) throws IOException { log.error(response.getStatusText()); } }); return restTemplate; }
Example #5
Source File: StandardSpanDecoratorTest.java From opentracing-toolbox with MIT License | 5 votes |
public StandardSpanDecoratorTest() { this.client.setErrorHandler(new DefaultResponseErrorHandler() { @Override public void handleError(final ClientHttpResponse response) { // don't throw } }); }
Example #6
Source File: OpenTracingServletExtensionAutoConfigurationTest.java From opentracing-toolbox with MIT License | 5 votes |
public OpenTracingServletExtensionAutoConfigurationTest() { this.client.setErrorHandler(new DefaultResponseErrorHandler() { @Override public void handleError(final ClientHttpResponse response) { // nothing to do } }); }
Example #7
Source File: OpenTracingWebExtensionAutoConfigurationTest.java From opentracing-toolbox with MIT License | 5 votes |
public OpenTracingWebExtensionAutoConfigurationTest() { this.client.setErrorHandler(new DefaultResponseErrorHandler() { @Override public void handleError(final ClientHttpResponse response) { // nothing to do } }); }
Example #8
Source File: StandardSpanDecoratorTest.java From opentracing-toolbox with MIT License | 5 votes |
public StandardSpanDecoratorTest() { this.client.setErrorHandler(new DefaultResponseErrorHandler() { @Override public void handleError(final ClientHttpResponse response) { // don't throw } }); }
Example #9
Source File: AssertingRestTemplate.java From spring-cloud-sleuth with Apache License 2.0 | 5 votes |
public AssertingRestTemplate() { setErrorHandler(new DefaultResponseErrorHandler() { @Override public void handleError(ClientHttpResponse response) throws IOException { if (hasError(response)) { log.error("Response has status code [" + response.getStatusCode() + "] and text [" + response.getStatusText() + "])"); } } }); }
Example #10
Source File: BaseResourceServerConfigurerAdapter.java From smaker with GNU Lesser General Public License v3.0 | 5 votes |
@Bean @Primary @LoadBalanced public RestTemplate lbRestTemplate() { RestTemplate restTemplate = new RestTemplate(); restTemplate.setErrorHandler(new DefaultResponseErrorHandler() { @Override public void handleError(ClientHttpResponse response) throws IOException { if (response.getRawStatusCode() != HttpStatus.BAD_REQUEST.value()) { super.handleError(response); } } }); return restTemplate; }
Example #11
Source File: AuthenticatedRestTemplate.java From mojito with Apache License 2.0 | 5 votes |
void setErrorHandlerWithLogging(RestTemplate restTemplate) { this.restTemplate.setErrorHandler(new DefaultResponseErrorHandler() { @Override public void handleError(ClientHttpResponse response) throws IOException { try { super.handleError(response); } catch (HttpClientErrorException e) { logger.debug(e.getResponseBodyAsString()); throw e; } } }); }
Example #12
Source File: SmartlingClientConfiguration.java From mojito with Apache License 2.0 | 5 votes |
public OAuth2RestTemplate smartlingRestTemplate() { OAuth2RestTemplate oAuth2RestTemplate = new OAuth2RestTemplate(smartling(), new DefaultOAuth2ClientContext()); RestTemplateUtils restTemplateUtils = new RestTemplateUtils(); restTemplateUtils.enableFeature(oAuth2RestTemplate, DeserializationFeature.UNWRAP_ROOT_VALUE); AccessTokenProviderChain accessTokenProviderChain = new AccessTokenProviderChain(Arrays.asList( new SmartlingAuthorizationCodeAccessTokenProvider()) ); oAuth2RestTemplate.setAccessTokenProvider(accessTokenProviderChain); DefaultUriTemplateHandler defaultUriTemplateHandler = new DefaultUriTemplateHandler(); defaultUriTemplateHandler.setBaseUrl(baseUri); oAuth2RestTemplate.setUriTemplateHandler(defaultUriTemplateHandler); oAuth2RestTemplate.setErrorHandler(new DefaultResponseErrorHandler() { @Override public void handleError(ClientHttpResponse response) throws IOException { try { super.handleError(response); } catch (HttpClientErrorException e) { if (resttemplateLogger.isDebugEnabled()) { resttemplateLogger.debug(e.getResponseBodyAsString()); } throw e; } } }); return oAuth2RestTemplate; }
Example #13
Source File: EvolveConfiguration.java From mojito with Apache License 2.0 | 5 votes |
RestTemplate evolveRestTemplate() { RestTemplate restTemplate = new RestTemplate(); DefaultUriTemplateHandler defaultUriTemplateHandler = new DefaultUriTemplateHandler(); defaultUriTemplateHandler.setBaseUrl(evolveConfigurationProperties.getUrl()); restTemplate.setUriTemplateHandler(defaultUriTemplateHandler); restTemplate.getInterceptors().add(new ClientHttpRequestInterceptor() { @Override public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution) throws IOException { request.getHeaders().add(HttpHeaders.AUTHORIZATION, evolveConfigurationProperties.getToken()); return execution.execute(request, body); } }); restTemplate.setErrorHandler(new DefaultResponseErrorHandler() { @Override public void handleError(ClientHttpResponse response) throws IOException { try { super.handleError(response); } catch (HttpServerErrorException | HttpClientErrorException e) { resttemplateLogger.debug(e.getResponseBodyAsString()); throw e; } } }); return restTemplate; }
Example #14
Source File: CustomRemoteTokenServices.java From microservice-integration with MIT License | 5 votes |
public CustomRemoteTokenServices(RestTemplate restTemplate) { this.restTemplate = restTemplate; restTemplate.setErrorHandler(new DefaultResponseErrorHandler() { @Override // Ignore 400 public void handleError(ClientHttpResponse response) throws IOException { if (response.getRawStatusCode() != 400) { super.handleError(response); } } }); }
Example #15
Source File: CustomRemoteTokenServices.java From microservice-integration with MIT License | 5 votes |
public CustomRemoteTokenServices() { restTemplate = new RestTemplate(); ((RestTemplate) restTemplate).setErrorHandler(new DefaultResponseErrorHandler() { @Override // Ignore 400 public void handleError(ClientHttpResponse response) throws IOException { if (response.getRawStatusCode() != 400) { super.handleError(response); } } }); }
Example #16
Source File: JwtSsoResponseErrorHandler.java From wecube-platform with Apache License 2.0 | 4 votes |
public JwtSsoResponseErrorHandler() { this.errorHandler = new DefaultResponseErrorHandler(); }
Example #17
Source File: AbstractIntegrationTest.java From apollo with Apache License 2.0 | 4 votes |
@PostConstruct private void postConstruct() { System.setProperty("spring.profiles.active", "test"); restTemplate.setErrorHandler(new DefaultResponseErrorHandler()); }
Example #18
Source File: AbstractControllerTest.java From apollo with Apache License 2.0 | 4 votes |
@PostConstruct protected void postConstruct() { restTemplate.setErrorHandler(new DefaultResponseErrorHandler()); restTemplate.setMessageConverters(httpMessageConverters.getConverters()); }
Example #19
Source File: AbstractControllerTest.java From apollo with Apache License 2.0 | 4 votes |
@PostConstruct private void postConstruct() { restTemplate.setErrorHandler(new DefaultResponseErrorHandler()); restTemplate.setMessageConverters(httpMessageConverters.getConverters()); }
Example #20
Source File: AbstractBaseIntegrationTest.java From apollo with Apache License 2.0 | 4 votes |
@PostConstruct private void postConstruct() { restTemplate.setErrorHandler(new DefaultResponseErrorHandler()); }
Example #21
Source File: PiwikConfig.java From portal-de-servicos with MIT License | 4 votes |
@Bean public RestTemplate piwikRestTemplate() { RestTemplate restTemplate = new RestTemplate(); restTemplate.setErrorHandler(new RestTemplateErrorLogger(new DefaultResponseErrorHandler())); return restTemplate; }
Example #22
Source File: RestTemplateErrorLogger.java From portal-de-servicos with MIT License | 4 votes |
@Autowired public RestTemplateErrorLogger(DefaultResponseErrorHandler handler) { errorHandler = handler; }
Example #23
Source File: Yahoo2Template.java From cloudstreetmarket.com with GNU General Public License v3.0 | 4 votes |
protected ResponseErrorHandler errorHandler() { return new DefaultResponseErrorHandler(); }
Example #24
Source File: AbstractTwitterInboundChannelAdapter.java From spring-cloud-stream-app-starters with Apache License 2.0 | 4 votes |
protected AbstractTwitterInboundChannelAdapter(TwitterTemplate twitter) { this.twitter = twitter; // Fix to get round TwitterErrorHandler not handling 401s etc. this.twitter.getRestTemplate().setErrorHandler(new DefaultResponseErrorHandler()); this.setPhase(Integer.MAX_VALUE); }
Example #25
Source File: RestApiSecurityApplicationTest.java From flowable-engine with Apache License 2.0 | 4 votes |
@After public void tearDown() { restTemplate.setErrorHandler(new DefaultResponseErrorHandler()); }
Example #26
Source File: RestApiApplicationTest.java From flowable-engine with Apache License 2.0 | 4 votes |
@After public void tearDown() { restTemplate.setErrorHandler(new DefaultResponseErrorHandler()); }
Example #27
Source File: CircuitBreakersEndpointTest.java From failsafe-actuator with MIT License | 4 votes |
@PostConstruct public void configure() { this.http.getRestTemplate().setErrorHandler(new DefaultResponseErrorHandler()); }
Example #28
Source File: RestTemplateBuilderUnitTests.java From spring-vault with Apache License 2.0 | 3 votes |
@Test void shouldApplyErrorHandler() { ResponseErrorHandler errorHandler = new DefaultResponseErrorHandler(); RestTemplate restTemplate = RestTemplateBuilder.builder().endpoint(VaultEndpoint.create("localhost", 8200)) .errorHandler(errorHandler).build(); assertThat(restTemplate.getErrorHandler()).isSameAs(errorHandler); }
Example #29
Source File: RestTemplateBuilderUnitTests.java From spring-vault with Apache License 2.0 | 3 votes |
@Test void shouldApplyErrorHandlerViaCustomizer() { ResponseErrorHandler errorHandler = new DefaultResponseErrorHandler(); RestTemplate restTemplate = RestTemplateBuilder.builder().endpoint(VaultEndpoint.create("localhost", 8200)) .customizers(it -> it.setErrorHandler(errorHandler)).build(); assertThat(restTemplate.getErrorHandler()).isSameAs(errorHandler); }