From 7361ee437fe9a680b1f93412d46cd96d9d58bfcc Mon Sep 17 00:00:00 2001 From: michele Date: Wed, 28 Aug 2019 13:01:15 +0200 Subject: [PATCH] simplified ArangoCollectionAsyncImpl handleGetDocumentExceptions --- .../internal/ArangoCollectionAsyncImpl.java | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/arangodb/internal/ArangoCollectionAsyncImpl.java b/src/main/java/com/arangodb/internal/ArangoCollectionAsyncImpl.java index 003dc79..7d93e5e 100644 --- a/src/main/java/com/arangodb/internal/ArangoCollectionAsyncImpl.java +++ b/src/main/java/com/arangodb/internal/ArangoCollectionAsyncImpl.java @@ -34,6 +34,7 @@ /** * @author Mark Vollmary + * @author Michele Rastelli */ public class ArangoCollectionAsyncImpl extends InternalArangoCollection @@ -118,18 +119,8 @@ public CompletableFuture getDocument( private Function handleGetDocumentExceptions(Boolean isCatchException) { return throwable -> { - ArangoDBException arangoDBException = null; - - if (throwable instanceof ArangoDBException) { - arangoDBException = (ArangoDBException) throwable; - } else if (throwable instanceof CompletionException) { - CompletionException completionException = (CompletionException) throwable; - if (completionException.getCause() instanceof ArangoDBException) { - arangoDBException = (ArangoDBException) completionException.getCause(); - } - } - - if (arangoDBException != null) { + if (throwable instanceof CompletionException && throwable.getCause() instanceof ArangoDBException) { + ArangoDBException arangoDBException = (ArangoDBException) throwable.getCause(); if ((arangoDBException.getResponseCode() != null && (arangoDBException.getResponseCode() == 404 || arangoDBException.getResponseCode() == 304 || arangoDBException.getResponseCode() == 412)) && isCatchException) { return null;