File tree Expand file tree Collapse file tree 1 file changed +6
-5
lines changed
metamorph/src/main/java/org/metafacture/metamorph/functions Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change 21
21
import org .metafacture .metamorph .api .MorphExecutionException ;
22
22
import org .metafacture .metamorph .api .helpers .AbstractSimpleStatelessFunction ;
23
23
24
- import java .io .FileNotFoundException ;
24
+ import java .io .IOException ;
25
+ import java .io .Reader ;
25
26
import javax .script .Invocable ;
26
27
import javax .script .ScriptEngine ;
27
28
import javax .script .ScriptEngineManager ;
@@ -60,14 +61,14 @@ public void setInvoke(final String invoke) {
60
61
public void setFile (final String file ) {
61
62
final ScriptEngineManager manager = new ScriptEngineManager ();
62
63
final ScriptEngine engine = manager .getEngineByName ("JavaScript" );
63
- try {
64
- // TODO: The script file should be loaded relatively to the base URI
65
- engine .eval (ResourceUtil . getReader ( file ) );
64
+ // TODO: The script file should be loaded relatively to the base URI
65
+ try ( Reader reader = ResourceUtil . getReader ( file )) {
66
+ engine .eval (reader );
66
67
}
67
68
catch (final ScriptException e ) {
68
69
throw new MorphBuildException ("Error in script" , e );
69
70
}
70
- catch (final FileNotFoundException e ) {
71
+ catch (final IOException e ) {
71
72
throw new MorphBuildException ("Error loading script '" + file + "'" , e );
72
73
}
73
74
invocable = (Invocable ) engine ;
You can’t perform that action at this time.
0 commit comments