summaryrefslogtreecommitdiff
path: root/scripting
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2016-08-19 14:08:57 +0100
committerCaolán McNamara <caolanm@redhat.com>2016-08-19 14:09:38 +0100
commitd02941ebdb023a6e3151878375a0ffbd163d9d51 (patch)
tree5fdfb062d00f21386752ea7e821013120ba15f3a /scripting
parent3f8b89e2b0c598c1a8a6e09b0b7d3cc1dc3133a6 (diff)
Revert "coverity#1371372 Resource leak on an exceptional path"
seeing as it doesn't build universally, java 1.7 onwards apparently This reverts commit 6830d8c2083fa66cc113f587cbfc4aa5a4f8a535.
Diffstat (limited to 'scripting')
-rw-r--r--scripting/java/com/sun/star/script/framework/provider/ClassLoaderFactory.java6
-rw-r--r--scripting/java/com/sun/star/script/framework/provider/beanshell/ScriptEditorForBeanShell.java12
-rw-r--r--scripting/java/com/sun/star/script/framework/provider/beanshell/ScriptProviderForBeanShell.java10
-rw-r--r--scripting/java/com/sun/star/script/framework/provider/javascript/ScriptProviderForJavaScript.java10
4 files changed, 8 insertions, 30 deletions
diff --git a/scripting/java/com/sun/star/script/framework/provider/ClassLoaderFactory.java b/scripting/java/com/sun/star/script/framework/provider/ClassLoaderFactory.java
index 73ba06938884..b3f3c50b8603 100644
--- a/scripting/java/com/sun/star/script/framework/provider/ClassLoaderFactory.java
+++ b/scripting/java/com/sun/star/script/framework/provider/ClassLoaderFactory.java
@@ -31,7 +31,7 @@ public class ClassLoaderFactory {
private ClassLoaderFactory() {}
- public static URLClassLoader getURLClassLoader(ScriptMetaData scriptData) {
+ public static ClassLoader getURLClassLoader(ScriptMetaData scriptData) {
ClassLoader parent = scriptData.getClass().getClassLoader();
URL[] classPath = scriptData.getClassPath();
LogUtils.DEBUG("Classpath has length " + classPath.length);
@@ -43,8 +43,8 @@ public class ClassLoaderFactory {
return getURLClassLoader(parent, classPath);
}
- private static URLClassLoader getURLClassLoader(ClassLoader parent,
+ private static ClassLoader getURLClassLoader(ClassLoader parent,
URL[] classpath) {
return new URLClassLoader(classpath, parent);
}
-}
+} \ No newline at end of file
diff --git a/scripting/java/com/sun/star/script/framework/provider/beanshell/ScriptEditorForBeanShell.java b/scripting/java/com/sun/star/script/framework/provider/beanshell/ScriptEditorForBeanShell.java
index b444cce8e46f..c832e6ed691f 100644
--- a/scripting/java/com/sun/star/script/framework/provider/beanshell/ScriptEditorForBeanShell.java
+++ b/scripting/java/com/sun/star/script/framework/provider/beanshell/ScriptEditorForBeanShell.java
@@ -35,7 +35,6 @@ import java.io.InputStream;
import java.io.OutputStream;
import java.net.URL;
-import java.net.URLClassLoader;
import java.util.HashMap;
import java.util.Map;
@@ -181,14 +180,15 @@ public class ScriptEditorForBeanShell implements ScriptEditor, ActionListener {
*/
public void edit(final XScriptContext context, ScriptMetaData entry) {
if (entry != null) {
- URLClassLoader cl = null;
try {
+ ClassLoader cl = null;
+
try {
cl = ClassLoaderFactory.getURLClassLoader(entry);
} catch (Exception ignore) { // TODO re-examine error handling
}
- final URLClassLoader theCl = cl;
+ final ClassLoader theCl = cl;
final URL url = entry.getSourceURL();
SwingInvocation.invoke(
new Runnable() {
@@ -210,12 +210,6 @@ public class ScriptEditorForBeanShell implements ScriptEditor, ActionListener {
});
} catch (IOException ioe) {
showErrorMessage("Error loading file: " + ioe.getMessage());
- if (cl != null) {
- try {
- cl.close();
- } catch (IOException e) {
- }
- }
}
}
}
diff --git a/scripting/java/com/sun/star/script/framework/provider/beanshell/ScriptProviderForBeanShell.java b/scripting/java/com/sun/star/script/framework/provider/beanshell/ScriptProviderForBeanShell.java
index 76ee4eff55f7..2aabba71242b 100644
--- a/scripting/java/com/sun/star/script/framework/provider/beanshell/ScriptProviderForBeanShell.java
+++ b/scripting/java/com/sun/star/script/framework/provider/beanshell/ScriptProviderForBeanShell.java
@@ -49,9 +49,7 @@ import com.sun.star.uno.Any;
import com.sun.star.uno.Type;
import com.sun.star.uno.XComponentContext;
-import java.io.IOException;
import java.net.URL;
-import java.net.URLClassLoader;
import java.util.StringTokenizer;
@@ -184,19 +182,13 @@ class ScriptImpl implements XScript {
aOutParamIndex[0] = new short[0];
aOutParam[0] = new Object[0];
- URLClassLoader cl = null;
+ ClassLoader cl = null;
URL sourceUrl = null;
try {
cl = ClassLoaderFactory.getURLClassLoader(metaData);
sourceUrl = metaData.getSourceURL();
} catch (java.net.MalformedURLException mfu) {
- if (cl != null) {
- try {
- cl.close();
- } catch (IOException e) {
- }
- }
// Framework error
throw new ScriptFrameworkErrorException(
mfu.getMessage(), null,
diff --git a/scripting/java/com/sun/star/script/framework/provider/javascript/ScriptProviderForJavaScript.java b/scripting/java/com/sun/star/script/framework/provider/javascript/ScriptProviderForJavaScript.java
index 359ac4a2632e..9465a646f64d 100644
--- a/scripting/java/com/sun/star/script/framework/provider/javascript/ScriptProviderForJavaScript.java
+++ b/scripting/java/com/sun/star/script/framework/provider/javascript/ScriptProviderForJavaScript.java
@@ -44,9 +44,7 @@ import com.sun.star.script.provider.XScript;
import com.sun.star.uno.XComponentContext;
-import java.io.IOException;
import java.net.URL;
-import java.net.URLClassLoader;
import org.mozilla.javascript.Context;
import org.mozilla.javascript.ImporterTopLevel;
@@ -183,18 +181,12 @@ class ScriptImpl implements XScript {
aOutParamIndex[0] = new short[0];
aOutParam[0] = new Object[0];
- URLClassLoader cl = null;
+ ClassLoader cl = null;
try {
cl = ClassLoaderFactory.getURLClassLoader(metaData);
metaData.getSourceURL();
} catch (java.net.MalformedURLException mfu) {
- if (cl != null) {
- try {
- cl.close();
- } catch (IOException e) {
- }
- }
throw new ScriptFrameworkErrorException(
mfu.getMessage(), null,
metaData.getLanguageName(), metaData.getLanguage(),