From: Kai Moritz Date: Thu, 21 Nov 2019 15:55:29 +0000 (+0100) Subject: WIP: WebClient X-Git-Tag: wip-webclient~18 X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=9182948a757827d7d8eeff3dac68cfd3d228706c;p=facebook-errors WIP: WebClient --- diff --git a/src/main/java/de/juplo/facebook/errors/GraphApiException.java b/src/main/java/de/juplo/facebook/errors/GraphApiException.java index 27f359f..ce3836c 100644 --- a/src/main/java/de/juplo/facebook/errors/GraphApiException.java +++ b/src/main/java/de/juplo/facebook/errors/GraphApiException.java @@ -49,15 +49,10 @@ public class GraphApiException extends RuntimeException public static Mono create(ClientResponse response) { - return DataBufferUtils.join(response.body(BodyExtractors.toDataBuffers())) - .map(dataBuffer -> { - byte[] bytes = new byte[dataBuffer.readableByteCount()]; - dataBuffer.read(bytes); - DataBufferUtils.release(dataBuffer); - return bytes; - }) - .defaultIfEmpty(new byte[0]) - .map(bytes -> create(response.statusCode(), response.headers().asHttpHeaders(), bytes)); + return + response + .createException() + .map(we -> create(response.statusCode(), response.headers().asHttpHeaders(), we.getResponseBodyAsByteArray())); } public static GraphApiException create(