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

rbuj robert.buj at gmail.com
Wed Sep 10 23:14:10 PDT 2014


 scripting/java/com/sun/star/script/framework/browse/ScriptBrowseNode.java |   49 ++++------
 1 file changed, 23 insertions(+), 26 deletions(-)

New commits:
commit b50fedfc348eb9a834b6626dc95e3538c4962a47
Author: rbuj <robert.buj at gmail.com>
Date:   Sat Sep 6 21:15:33 2014 +0200

    scripting: avoid a possible NullPointerException
    
    Change-Id: I90589bc042f4b88b700e9f3c167c460c3cff043c
    Reviewed-on: https://gerrit.libreoffice.org/11311
    Reviewed-by: Noel Grandin <noelgrandin at gmail.com>
    Tested-by: Noel Grandin <noelgrandin at gmail.com>

diff --git a/scripting/java/com/sun/star/script/framework/browse/ScriptBrowseNode.java b/scripting/java/com/sun/star/script/framework/browse/ScriptBrowseNode.java
index 5c744b1..6073eb0 100644
--- a/scripting/java/com/sun/star/script/framework/browse/ScriptBrowseNode.java
+++ b/scripting/java/com/sun/star/script/framework/browse/ScriptBrowseNode.java
@@ -64,46 +64,43 @@ public class ScriptBrowseNode extends PropertySet
         this.provider = provider;
         this.name = name;
         this.parent = parent;
-        ScriptMetaData data = null;
-        XSimpleFileAccess xSFA = null;
         XComponentContext xCtx = provider.getScriptingContext().getComponentContext();
         XMultiComponentFactory xFac = xCtx.getServiceManager();
         try
         {
-            data = (ScriptMetaData)parent.getByName( name );
-            xSFA = UnoRuntime.queryInterface( XSimpleFileAccess.class,
+            ScriptMetaData data = (ScriptMetaData)parent.getByName( name );
+            XSimpleFileAccess xSFA = UnoRuntime.queryInterface( XSimpleFileAccess.class,
                 xFac.createInstanceWithContext(
                     "com.sun.star.ucb.SimpleFileAccess",
                     xCtx ) );
-        }
-
-        // TODO fix exception types to be caught here, should we rethrow?
-        catch (  Exception e )
-        {
-            LogUtils.DEBUG("** caught exception getting script data for " + name + " ->" + e.toString() );
-        }
-
-        if (provider.hasScriptEditor())
-        {
 
-            this.editable  = true;
-            try
+            if (provider.hasScriptEditor())
             {
-                if ( !parent.isUnoPkg() &&
-                    !xSFA.isReadOnly( parent.getPathToParcel() ) )
+                this.editable = true;
+                try
                 {
-                    this.deletable = true;
-                    this.renamable = true;
+                    if (!parent.isUnoPkg()
+                            && !xSFA.isReadOnly(parent.getPathToParcel()))
+                    {
+                        this.deletable = true;
+                        this.renamable = true;
+                    }
                 }
-            }
-            // TODO propagate errors
-            catch ( Exception e )
-            {
-                LogUtils.DEBUG("Caught exception in creation of ScriptBrowseNode");
-                LogUtils.DEBUG( LogUtils.getTrace(e));
+                // TODO propagate errors
+                catch (Exception e)
+                {
+                    LogUtils.DEBUG("Caught exception in creation of ScriptBrowseNode");
+                    LogUtils.DEBUG(LogUtils.getTrace(e));
+                }
+
             }
 
         }
+        // TODO fix exception types to be caught here, should we rethrow?
+        catch (  Exception e )
+        {
+            LogUtils.DEBUG("** caught exception getting script data for " + name + " ->" + e.toString() );
+        }
 
         registerProperty("Deletable", new Type(boolean.class),
             (short)0, "deletable");


More information about the Libreoffice-commits mailing list