Skip to content

Commit 7361ee4

Browse files
author
michele
committed
simplified ArangoCollectionAsyncImpl handleGetDocumentExceptions
1 parent fa75f4e commit 7361ee4

File tree

1 file changed

+3
-12
lines changed

1 file changed

+3
-12
lines changed

β€Žsrc/main/java/com/arangodb/internal/ArangoCollectionAsyncImpl.java

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434

3535
/**
3636
* @author Mark Vollmary
37+
* @author Michele Rastelli
3738
*/
3839
public class ArangoCollectionAsyncImpl
3940
extends InternalArangoCollection<ArangoDBAsyncImpl, ArangoDatabaseAsyncImpl, ArangoExecutorAsync>
@@ -118,18 +119,8 @@ public <T> CompletableFuture<T> getDocument(
118119

119120
private <T> Function<Throwable, T> handleGetDocumentExceptions(Boolean isCatchException) {
120121
return throwable -> {
121-
ArangoDBException arangoDBException = null;
122-
123-
if (throwable instanceof ArangoDBException) {
124-
arangoDBException = (ArangoDBException) throwable;
125-
} else if (throwable instanceof CompletionException) {
126-
CompletionException completionException = (CompletionException) throwable;
127-
if (completionException.getCause() instanceof ArangoDBException) {
128-
arangoDBException = (ArangoDBException) completionException.getCause();
129-
}
130-
}
131-
132-
if (arangoDBException != null) {
122+
if (throwable instanceof CompletionException && throwable.getCause() instanceof ArangoDBException) {
123+
ArangoDBException arangoDBException = (ArangoDBException) throwable.getCause();
133124
if ((arangoDBException.getResponseCode() != null && (arangoDBException.getResponseCode() == 404 || arangoDBException.getResponseCode() == 304
134125
|| arangoDBException.getResponseCode() == 412)) && isCatchException) {
135126
return null;

0 commit comments

Comments
 (0)