WIP: WebClient
authorKai Moritz <kai@jupl.de>
Thu, 21 Nov 2019 13:47:37 +0000 (14:47 +0100)
committerKai Moritz <kai@jupl.de>
Thu, 21 Nov 2019 13:47:37 +0000 (14:47 +0100)
src/main/java/de/juplo/facebook/errors/GraphApiException.java

index 5ec30fa..b82a05b 100644 (file)
@@ -50,12 +50,12 @@ public class GraphApiException extends RuntimeException
   public static GraphApiException create(ClientResponse response)
   {
     return
-        response.body((ReactiveHttpInputMessage message, Context context) ->
-        {
-          DataBuffer buffer = message.getBody().blockFirst();
-          InputStream is = message.getBody().blockFirst().asInputStream();
-          return create(response.statusCode(), message.getHeaders(), is);
-        });
+        response
+            .body((ReactiveHttpInputMessage message, Context context) ->
+                message
+                    .getBody()
+                    .map(buffer -> buffer.asInputStream()))
+            .flatMap(is -> create(response.statusCode(), message.getHeaders(), is));
   }
 
   public static GraphApiException create(