hasErrors.set(true);
return Pair.with(f, Optional.<FileReader>empty());
}
}).filter(p -> p.getValue1().isPresent()).map(p -> Pair.with(p.getValue0(), p.getValue1().get())).forEachOrdered(p -> {
try {
final Bindings bindings = new SimpleBindings();
bindings.putAll(this.globalBindings);
// evaluate init scripts with hard reference so as to ensure it doesn't get garbage collected
bindings.put(GremlinGroovyScriptEngine.KEY_REFERENCE_TYPE, GremlinGroovyScriptEngine.REFERENCE_TYPE_HARD);
se.eval(p.getValue1(), bindings, language);
// re-assign graph bindings back to global bindings. prevent assignment of non-graph
// implementations just in case someone tries to overwrite them in the init
bindings.entrySet().stream()
.filter(kv -> kv.getValue() instanceof Graph)
.forEach(kv -> this.globalBindings.put(kv.getKey(), kv.getValue()));
logger.info("Initialized {} ScriptEngine with {}", language, p.getValue0());
} catch (ScriptException sx) {