Skip to content

Commit

Permalink
Handle ServiceUnavailableException after driver version upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
nmervaillie committed May 26, 2017
1 parent c8b13f6 commit e1bbff8
Showing 1 changed file with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2002-2016 "Neo Technology,"
* Copyright (c) 2002-2017 "Neo Technology,"
* Network Engine for Objects in Lund AB [http://neotechnology.com]
*
* This product is licensed to you under the Apache License, Version 2.0 (the "License").
Expand All @@ -22,6 +22,7 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import org.neo4j.driver.v1.StatementResult;
import org.neo4j.driver.v1.exceptions.ClientException;
import org.neo4j.driver.v1.exceptions.ServiceUnavailableException;
import org.neo4j.ogm.drivers.bolt.response.GraphModelResponse;
import org.neo4j.ogm.drivers.bolt.response.GraphRowModelResponse;
import org.neo4j.ogm.drivers.bolt.response.RestModelResponse;
Expand All @@ -34,13 +35,7 @@
import org.neo4j.ogm.model.GraphRowListModel;
import org.neo4j.ogm.model.RestModel;
import org.neo4j.ogm.model.RowModel;
import org.neo4j.ogm.request.DefaultRequest;
import org.neo4j.ogm.request.GraphModelRequest;
import org.neo4j.ogm.request.GraphRowListModelRequest;
import org.neo4j.ogm.request.Request;
import org.neo4j.ogm.request.RestModelRequest;
import org.neo4j.ogm.request.RowModelRequest;
import org.neo4j.ogm.request.Statement;
import org.neo4j.ogm.request.*;
import org.neo4j.ogm.response.EmptyResponse;
import org.neo4j.ogm.response.Response;
import org.neo4j.ogm.transaction.TransactionManager;
Expand Down Expand Up @@ -161,6 +156,12 @@ private StatementResult executeRequest(Statement request) {
return tx.nativeBoltTransaction().run(request.getStatement(), parameterMap);
} catch (CypherException|ConnectionException ce) {
throw ce;
} catch (ServiceUnavailableException ce) {
tx = (BoltTransaction) transactionManager.getCurrentTransaction();
if (tx != null) {
tx.rollback();
}
throw new ConnectionException("Unable to access the database " + ce.getMessage(), ce);
} catch (ClientException ce) {
tx = (BoltTransaction) transactionManager.getCurrentTransaction();
if (tx != null) {
Expand Down

0 comments on commit e1bbff8

Please sign in to comment.