You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by db...@apache.org on 2010/05/11 12:57:59 UTC

svn commit: r943079 - in /felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime: Activator.java shell/Closure.java shell/CommandProcessorImpl.java shell/CommandProxy.java

Author: dbaum
Date: Tue May 11 10:57:58 2010
New Revision: 943079

URL: http://svn.apache.org/viewvc?rev=943079&view=rev
Log:
fix NPE in session.execute("a = $b x") when $b evaluates to null;
fix session.get(".commands") to be list of command names, rather than map.


Modified:
    felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Activator.java
    felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/shell/Closure.java
    felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/shell/CommandProcessorImpl.java
    felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/shell/CommandProxy.java

Modified: felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Activator.java
URL: http://svn.apache.org/viewvc/felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Activator.java?rev=943079&r1=943078&r2=943079&view=diff
==============================================================================
--- felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Activator.java (original)
+++ felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Activator.java Tue May 11 10:57:58 2010
@@ -53,6 +53,11 @@ public class Activator implements Bundle
     private OSGiCommands commands;
     private OSGiConverters converters;
     private ServiceRegistration convertersRegistration;
+    
+    protected CommandProcessorImpl newProcessor(ThreadIO tio)
+    {
+        return new CommandProcessorImpl(threadio);
+    }
 
     public void start(final BundleContext context) throws Exception
     {
@@ -61,7 +66,7 @@ public class Activator implements Bundle
         threadioRegistration = context.registerService(ThreadIO.class.getName(),
             threadio, null);
 
-        processor = new CommandProcessorImpl(threadio);
+        processor = newProcessor(threadio);
         processorRegistration = context.registerService(CommandProcessor.class.getName(),
             processor, null);
         

Modified: felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/shell/Closure.java
URL: http://svn.apache.org/viewvc/felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/shell/Closure.java?rev=943079&r1=943078&r2=943079&view=diff
==============================================================================
--- felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/shell/Closure.java (original)
+++ felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/shell/Closure.java Tue May 11 10:57:58 2010
@@ -45,6 +45,7 @@ public class Closure extends Reflective 
     private final Object script;
 
     private Token errTok;
+    private Token errTok2;
     private List<Object> parms = null;
     private List<Object> parmv = null;
 
@@ -289,6 +290,11 @@ public class Closure extends Reflective 
 
         List<Object> values = new ArrayList<Object>();
         errTok = statement.get(0);
+        
+        if ((statement.size() > 3) && Type.ASSIGN.equals(statement.get(1).type))
+        {
+            errTok2 = statement.get(2);
+        }
 
         for (Token t : statement)
         {
@@ -352,7 +358,12 @@ public class Closure extends Reflective 
                 }
                 else
                 {
-                    value = execute(values.get(1), values.subList(2, values.size()));
+                    cmd = values.get(1);
+                    if (null == cmd)
+                    {
+                        throw new RuntimeException("Command name evaluates to null: " + errTok2);
+                    }
+                    value = execute(cmd, values.subList(2, values.size()));
                 }
 
                 return assignment(scmd, value);

Modified: felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/shell/CommandProcessorImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/shell/CommandProcessorImpl.java?rev=943079&r1=943078&r2=943079&view=diff
==============================================================================
--- felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/shell/CommandProcessorImpl.java (original)
+++ felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/shell/CommandProcessorImpl.java Tue May 11 10:57:58 2010
@@ -62,9 +62,9 @@ public class CommandProcessorImpl implem
         converters.remove(c);
     }
     
-    public Map<String, Object> getCommands()
+    public Set<String> getCommands()
     {
-        return commands;
+        return commands.keySet();
     }
 
     public Function getCommand(String name)

Modified: felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/shell/CommandProxy.java
URL: http://svn.apache.org/viewvc/felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/shell/CommandProxy.java?rev=943079&r1=943078&r2=943079&view=diff
==============================================================================
--- felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/shell/CommandProxy.java (original)
+++ felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/shell/CommandProxy.java Tue May 11 10:57:58 2010
@@ -44,11 +44,16 @@ public class CommandProxy extends Reflec
         this.function = function;
         this.target = target;
     }
+    
+    public Object getTarget()
+    {
+        return (context != null ? context.getService(reference) : target);
+    }
 
     public Object execute(CommandSession session, List<Object> arguments)
         throws Exception
     {
-        Object tgt = (context != null ? context.getService(reference) : target);
+        Object tgt = getTarget();
         
         try
         {