From 9182948a757827d7d8eeff3dac68cfd3d228706c Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Thu, 21 Nov 2019 16:55:29 +0100 Subject: [PATCH] WIP: WebClient --- .../de/juplo/facebook/errors/GraphApiException.java | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) 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( -- 2.20.1