File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed
metafacture-scripting/src/main/java/org/metafacture/scripting Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change 25
25
import org .metafacture .framework .annotations .Out ;
26
26
import org .metafacture .framework .helpers .DefaultObjectPipe ;
27
27
28
- import java .io .FileNotFoundException ;
28
+ import java .io .IOException ;
29
+ import java .io .Reader ;
29
30
import javax .script .Invocable ;
30
31
import javax .script .ScriptEngine ;
31
32
import javax .script .ScriptEngineManager ;
@@ -70,14 +71,14 @@ private void setScript(final String file) {
70
71
71
72
final ScriptEngineManager manager = new ScriptEngineManager ();
72
73
final ScriptEngine engine = manager .getEngineByName ("JavaScript" );
73
- try {
74
+ try ( Reader reader = ResourceUtil . getReader ( file )) {
74
75
// LOG.info("loading code from '" + file + "'");
75
- engine .eval (ResourceUtil . getReader ( file ) );
76
+ engine .eval (reader );
76
77
}
77
78
catch (final ScriptException e ) {
78
79
throw new MetafactureException ("Error in script" , e );
79
80
}
80
- catch (final FileNotFoundException e ) {
81
+ catch (final IOException e ) {
81
82
throw new MetafactureException ("Error loading script '" + file + "'" , e );
82
83
}
83
84
invocable = (Invocable ) engine ;
You can’t perform that action at this time.
0 commit comments