Skip to content

Commit 1550191

Browse files
committed
fix bug
1 parent e58da54 commit 1550191

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

src/main/scala/org/grapheco/server/neo4j/executors.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ class GetNeighbours extends JsonCommandExecutor with Neo4jCommandExecutor {
8383
class GetNodesInfo extends JsonCommandExecutor with Neo4jCommandExecutor {
8484

8585
def execute(request: JsonObject): Map[String, _] = {
86+
8687
val ids = request.getAsJsonArray("nodeIds").map(_.getAsString).reduce(_ + "," + _);
8788
val query = s"match (n) where id(n) in [$ids] return n";
8889
Map("infos" ->

src/main/scala/org/grapheco/server/neo4j/services.scala

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class BoltService extends Logging with CypherService {
3737
var _url = "";
3838
var _user = "";
3939
var _pass = "";
40-
var _longDriver: Driver = null;
40+
var _driver:Driver = null;
4141
var _longSession: Session = null;
4242

4343
def setBoltUrl(value: String) = _url = value;
@@ -47,18 +47,20 @@ class BoltService extends Logging with CypherService {
4747
def setBoltPassword(value: String) = _pass = value;
4848

4949
override def execute[T](f: (Session) => T): T = {
50-
val driver = GraphDatabase.driver(_url, AuthTokens.basic(_user, _pass));
51-
val session = driver.session(AccessMode.READ);
50+
if(_driver==null){
51+
_driver = GraphDatabase.driver(_url, AuthTokens.basic(_user, _pass));
52+
}
53+
val session = _driver.session(AccessMode.READ);
5254
val result = f(session);
5355
session.close();
54-
driver.close();
56+
// driver.close();
5557
result;
5658
}
5759

5860
override def aliveExecute[T](f: Session => T): T = {
59-
if (this._longDriver == null || this._longSession == null) {
60-
this._longDriver = GraphDatabase.driver(_url, AuthTokens.basic(_user, _pass));
61-
this._longSession = this._longDriver.session(AccessMode.READ);
61+
if (this._driver == null || this._longSession == null) {
62+
this._driver = GraphDatabase.driver(_url, AuthTokens.basic(_user, _pass));
63+
this._longSession = this._driver.session(AccessMode.READ);
6264
}
6365
f(this._longSession);
6466
}

0 commit comments

Comments
 (0)