Kaydet (Commit) d02941eb authored tarafından Caolán McNamara's avatar Caolán McNamara

Revert "coverity#1371372 Resource leak on an exceptional path"

seeing as it doesn't build universally, java 1.7 onwards
apparently

This reverts commit 6830d8c2.
üst 3f8b89e2
......@@ -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
......@@ -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) {
}
}
}
}
}
......
......@@ -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,
......
......@@ -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(),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment