[Libreoffice-commits] core.git: scripting/java

Caolán McNamara caolanm at redhat.com
Fri Aug 19 13:10:03 UTC 2016


 scripting/java/com/sun/star/script/framework/provider/ClassLoaderFactory.java                     |    6 ++---
 scripting/java/com/sun/star/script/framework/provider/beanshell/ScriptEditorForBeanShell.java     |   12 ++--------
 scripting/java/com/sun/star/script/framework/provider/beanshell/ScriptProviderForBeanShell.java   |   10 --------
 scripting/java/com/sun/star/script/framework/provider/javascript/ScriptProviderForJavaScript.java |   10 --------
 4 files changed, 8 insertions(+), 30 deletions(-)

New commits:
commit d02941ebdb023a6e3151878375a0ffbd163d9d51
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Aug 19 14:08:57 2016 +0100

    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.

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 73ba069..b3f3c50 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 b444cce..c832e6e 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 76ee4ef..2aabba7 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 359ac4a..9465a64 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(),


More information about the Libreoffice-commits mailing list