We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fedor Bartosh opened SPR-12887 and commented
AsyncRestTemplate.execute returns ListenableFuture that allows to register callbacks. Let's say we have following example:
public void test() throws InterruptedException, ExecutionException { AsyncRestTemplate restTemplate = new AsyncRestTemplate(); String url = "http://graph.facebook.com/some-non-existing-resource"; ListenableFuture<ResponseEntity<Object>> responseEntity = restTemplate.exchange(url, HttpMethod.GET, HttpEntity.EMPTY, Object.class); final String[] listenerExceptionBody = new String[1]; String getExceptionBody = null; try { responseEntity.addCallback(new ListenableFutureCallback<ResponseEntity<Object>>() { @Override public void onFailure(Throwable throwable) { if (throwable instanceof HttpClientErrorException) { HttpClientErrorException exception = (HttpClientErrorException) throwable; listenerExceptionBody[0] = exception.getResponseBodyAsString(); } } @Override public void onSuccess(ResponseEntity<Object> objectResponseEntity) { System.out.println("onSuccess"); } }); Thread.sleep(100); responseEntity.get(); } catch (HttpClientErrorException e) { getExceptionBody = e.getResponseBodyAsString(); } Assert.assertEquals(listenerExceptionBody[0], getExceptionBody); }
If 4xx error occurs during REST call, two HttpClientErrorException will be created, one of them containing response body and another one missing.
Sample maven project is attached.
Affects: 4.1.6
Attachments:
Issue Links:
Referenced from: commits b119a9c, de0f3ae, 3402c13, b18053f
The text was updated successfully, but these errors were encountered:
Arjen Poutsma commented
Fixed. PR at #776
Sorry, something went wrong.
rstoyanchev
No branches or pull requests
Fedor Bartosh opened SPR-12887 and commented
AsyncRestTemplate.execute returns ListenableFuture that allows to register callbacks. Let's say we have following example:
If 4xx error occurs during REST call, two HttpClientErrorException will be created, one of them containing response body and another one missing.
Sample maven project is attached.
Affects: 4.1.6
Attachments:
Issue Links:
Referenced from: commits b119a9c, de0f3ae, 3402c13, b18053f
The text was updated successfully, but these errors were encountered: