diff --git a/echosvg-bridge/src/main/java/io/sf/carte/echosvg/bridge/BaseScriptingEnvironment.java b/echosvg-bridge/src/main/java/io/sf/carte/echosvg/bridge/BaseScriptingEnvironment.java index c49ae2722..db2f8ab8b 100644 --- a/echosvg-bridge/src/main/java/io/sf/carte/echosvg/bridge/BaseScriptingEnvironment.java +++ b/echosvg-bridge/src/main/java/io/sf/carte/echosvg/bridge/BaseScriptingEnvironment.java @@ -361,13 +361,13 @@ protected void loadScript(AbstractElement script) { // Java code invocation. // if (type.equals(SVGConstants.SVG_SCRIPT_TYPE_JAVA)) { + DocumentJarClassLoader cll = null; try { String href = XLinkSupport.getXLinkHref(script); ParsedURL purl = new ParsedURL(script.getBaseURI(), href); checkCompatibleScriptURL(type, purl); - DocumentJarClassLoader cll; URL docURL = null; try { docURL = new URL(docPURL.toString()); @@ -411,6 +411,15 @@ protected void loadScript(AbstractElement script) { if (userAgent != null) { userAgent.displayError(e); } + } finally { + try { + if (cll != null) + cll.close(); + } catch (IOException e) { + if (userAgent != null) { + userAgent.displayError(e); + } + } } return; }