Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
HC-teemo committed Aug 12, 2020
1 parent e58da54 commit 1550191
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
1 change: 1 addition & 0 deletions src/main/scala/org/grapheco/server/neo4j/executors.scala
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ class GetNeighbours extends JsonCommandExecutor with Neo4jCommandExecutor {
class GetNodesInfo extends JsonCommandExecutor with Neo4jCommandExecutor {

def execute(request: JsonObject): Map[String, _] = {

val ids = request.getAsJsonArray("nodeIds").map(_.getAsString).reduce(_ + "," + _);
val query = s"match (n) where id(n) in [$ids] return n";
Map("infos" ->
Expand Down
16 changes: 9 additions & 7 deletions src/main/scala/org/grapheco/server/neo4j/services.scala
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class BoltService extends Logging with CypherService {
var _url = "";
var _user = "";
var _pass = "";
var _longDriver: Driver = null;
var _driver:Driver = null;
var _longSession: Session = null;

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

override def execute[T](f: (Session) => T): T = {
val driver = GraphDatabase.driver(_url, AuthTokens.basic(_user, _pass));
val session = driver.session(AccessMode.READ);
if(_driver==null){
_driver = GraphDatabase.driver(_url, AuthTokens.basic(_user, _pass));
}
val session = _driver.session(AccessMode.READ);
val result = f(session);
session.close();
driver.close();
// driver.close();
result;
}

override def aliveExecute[T](f: Session => T): T = {
if (this._longDriver == null || this._longSession == null) {
this._longDriver = GraphDatabase.driver(_url, AuthTokens.basic(_user, _pass));
this._longSession = this._longDriver.session(AccessMode.READ);
if (this._driver == null || this._longSession == null) {
this._driver = GraphDatabase.driver(_url, AuthTokens.basic(_user, _pass));
this._longSession = this._driver.session(AccessMode.READ);
}
f(this._longSession);
}
Expand Down

0 comments on commit 1550191

Please sign in to comment.