Skip to content

Commit

Permalink
Fix NPE on dijkstra() and astar() functions
Browse files Browse the repository at this point in the history
Resolves: #7818
  • Loading branch information
luigidellaquila committed Oct 30, 2017
1 parent b8011ac commit f523d42
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ public LinkedList<OVertex> execute(final Object iThis, final OIdentifiable iCurr
bindAdditionalParams(iParams[3], context);
}
iContext.setVariable("getNeighbors", 0);
if (paramSourceVertex == null || paramDestinationVertex == null) {
return new LinkedList<>();
}
return internalExecute(iContext, iContext.getDatabase());

}
Expand Down Expand Up @@ -243,8 +246,8 @@ private void bindAdditionalParams(Object additionalParams, OSQLFunctionAstar ctx
ctx.paramDFactor = doubleOrDefault(mapParams.get(OSQLFunctionAstar.PARAM_D_FACTOR), ctx.paramDFactor);
if (mapParams.get(OSQLFunctionAstar.PARAM_HEURISTIC_FORMULA) != null) {
if (mapParams.get(OSQLFunctionAstar.PARAM_HEURISTIC_FORMULA) instanceof String) {
ctx.paramHeuristicFormula = HeuristicFormula
.valueOf(stringOrDefault(mapParams.get(OSQLFunctionAstar.PARAM_HEURISTIC_FORMULA), "MANHATAN").toUpperCase(Locale.ENGLISH));
ctx.paramHeuristicFormula = HeuristicFormula.valueOf(
stringOrDefault(mapParams.get(OSQLFunctionAstar.PARAM_HEURISTIC_FORMULA), "MANHATAN").toUpperCase(Locale.ENGLISH));
} else {
ctx.paramHeuristicFormula = (HeuristicFormula) mapParams.get(OSQLFunctionAstar.PARAM_HEURISTIC_FORMULA);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ public LinkedList<OrientVertex> execute(final Object iThis, final OIdentifiable
bindAdditionalParams(iParams[3], context);
}
iContext.setVariable("getNeighbors", 0);
if (paramSourceVertex == null || paramDestinationVertex == null) {
return new LinkedList<>();
}
return internalExecute(iContext, graph);
}
});
Expand Down

0 comments on commit f523d42

Please sign in to comment.