@SuppressWarnings("unchecked") @Override public Class<? extends T> getPayloadType() throws UnsupportedOperationException { return (Class<? extends T>) (Class<?>) type.getType(); }
@Override public <E> Mono<E> asMono(ResponseType<E> entityType) { return response.bodyToMono(ParameterizedTypeReference.forType(entityType.getType())); }
@Override public <T, R> Optional<T> invokeForEntity(HttpMethod method, RequestEntity<R> requestEntity, ResponseType<T> responseType) { ResponseEntity<T> response = invoker.invoke(this, method, requestEntity, responseType, true); if (response == null) { throw new HttpClientInvocationException("The invoker [" + invoker + "] returned a null response"); } try { return response.getPayload(); } catch (Exception e) { throw new HttpClientInvocationException(e); } finally { if (responseType != null && InputStream.class != responseType.getType()) { try { response.close(); } catch (Exception e) { LOGGER.debug(() -> "Failed to close the response", e); } } } }