private void writeHeaders(Response response, RestClientResponseException re) { //headers. if(null != re.getResponseHeaders()) { re.getResponseHeaders().forEach((name, list) -> { for (String value : list) { response.addHeader(name, value); } }); } }
private Long getRetryAfter(Exception candidate) { if (candidate instanceof RestClientResponseException) { String retryAfter = ((RestClientResponseException) candidate).getResponseHeaders().getFirst(RETRY_AFTER); if (retryAfter != null) { return System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(Long.parseLong(retryAfter)); } } return null; }
@ExceptionHandler @ResponseBody public ResponseEntity<Object> handleRestClientResponseException(RestClientResponseException e, WebRequest request) { return handleExceptionInternal(e, e.getResponseBodyAsByteArray(), e.getResponseHeaders(), HttpStatus.valueOf(e.getRawStatusCode()), request); }
@ExceptionHandler @ResponseBody public ResponseEntity<Object> handleRestClientResponseException(RestClientResponseException e, WebRequest request) { return handleExceptionInternal(e, e.getResponseBodyAsByteArray(), e.getResponseHeaders(), HttpStatus.valueOf(e.getRawStatusCode()), request); }