Source:
<code>static Mono<Object> decode(HttpResponse httpResponse, SerializerAdapter serializer, HttpResponseDecodeData decodeData) { ensureRequestSet(httpResponse); <START> final ClientLogger logger = new ClientLogger(HttpResponseBodyDecoder.class); <END> return Mono.defer(() -> { if (isErrorStatus(httpResponse, decodeData)) { return httpResponse.getBodyAsString() .flatMap(bodyString -> { try { final Object decodedErrorEntity = deserializeBody(bodyString, decodeData.getUnexpectedException(httpResponse.getStatusCode()).getExceptionBodyType(), null, serializer, SerializerEncoding.fromHeaders(httpResponse.getHeaders())); return decodedErrorEntity == null ? Mono.empty() : Mono.just(decodedErrorEntity); } catch (IOException | MalformedValueException ignored) { logger.warning("Failed to deserialize the error entity. Error details: " + ignored.getMessage()); } return Mono.empty(); }); } else if (httpResponse.getRequest().getHttpMethod() == HttpMethod.HEAD) { return Mono.empty(); } else if (!isReturnTypeDecodable(decodeData)) { return Mono.empty(); } else { return httpResponse.getBodyAsString() .flatMap(bodyString -> { try { final Object decodedSuccessEntity = deserializeBody(bodyString, extractEntityTypeFromReturnType(decodeData), decodeData.getReturnValueWireType(), serializer, SerializerEncoding.fromHeaders(httpResponse.getHeaders())); return decodedSuccessEntity == null ? Mono.empty() : Mono.just(decodedSuccessEntity); } catch (MalformedValueException e) { return Mono.error(new HttpResponseException("HTTP response has a malformed body.", httpResponse, e)); } catch (IOException e) { return Mono.error(new HttpResponseException("Deserialization Failed.", httpResponse, e)); } }); } }); }</code><technical_language>Creating a new instance time get expensive (if complex initialisation logic). sadly, this is a static method/class</technical_language>

Target:
static Mono<Object> decode(HttpResponse httpResponse, SerializerAdapter serializer, HttpResponseDecodeData decodeData) { ensureRequestSet(httpResponse); final ClientLogger logger = new ClientLogger(HttpResponseBodyDecoder.class); return Mono.defer(() -> { if (isErrorStatus(httpResponse, decodeData)) { return httpResponse.getBodyAsString() .flatMap(bodyString -> { try { final Object decodedErrorEntity = deserializeBody(bodyString, decodeData.getUnexpectedException(httpResponse.getStatusCode()).getExceptionBodyType(), null, serializer, SerializerEncoding.fromHeaders(httpResponse.getHeaders())); return decodedErrorEntity == null ? Mono.empty() : Mono.just(decodedErrorEntity); } catch (IOException | MalformedValueException ex) { logger.warning("Failed to deserialize the error entity.", ex); } return Mono.empty(); }); } else if (httpResponse.getRequest().getHttpMethod() == HttpMethod.HEAD) { return Mono.empty(); } else if (!isReturnTypeDecodable(decodeData)) { return Mono.empty(); } else { return httpResponse.getBodyAsString() .flatMap(bodyString -> { try { final Object decodedSuccessEntity = deserializeBody(bodyString, extractEntityTypeFromReturnType(decodeData), decodeData.getReturnValueWireType(), serializer, SerializerEncoding.fromHeaders(httpResponse.getHeaders())); return decodedSuccessEntity == null ? Mono.empty() : Mono.just(decodedSuccessEntity); } catch (MalformedValueException e) { return Mono.error(new HttpResponseException("HTTP response has a malformed body.", httpResponse, e)); } catch (IOException e) { return Mono.error(new HttpResponseException("Deserialization Failed.", httpResponse, e)); } }); } }); }