felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From db...@apache.org
Subject svn commit: r962374 - in /felix/trunk/gogo/runtime/src: main/java/org/apache/felix/gogo/runtime/Closure.java main/java/org/apache/felix/gogo/runtime/Tokenizer.java test/java/org/apache/felix/gogo/runtime/TestParser2.java
Date Fri, 09 Jul 2010 00:22:18 GMT
Author: dbaum
Date: Fri Jul  9 00:22:18 2010
New Revision: 962374

URL: http://svn.apache.org/viewvc?rev=962374&view=rev
Log:
FELIX-2468 don't coerce CharSequence types to String

Modified:
    felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Closure.java
    felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Tokenizer.java
    felix/trunk/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/TestParser2.java

Modified: felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Closure.java
URL: http://svn.apache.org/viewvc/felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Closure.java?rev=962374&r1=962373&r2=962374&view=diff
==============================================================================
--- felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Closure.java (original)
+++ felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Closure.java Fri
Jul  9 00:22:18 2010
@@ -111,7 +111,6 @@ public class Closure implements Function
     }
 
     // implements Function interface
-    // XXX: session arg x not used?
     public Object execute(CommandSession x, List<Object> values) throws Exception
     {
         try
@@ -257,10 +256,6 @@ public class Closure implements Function
                 {
                     v = eval(v);
                 }
-                else if (v instanceof CharSequence)
-                {
-                    v = v.toString();
-                }
                 break;
 
             case CLOSURE:

Modified: felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Tokenizer.java
URL: http://svn.apache.org/viewvc/felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Tokenizer.java?rev=962374&r1=962373&r2=962374&view=diff
==============================================================================
--- felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Tokenizer.java (original)
+++ felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Tokenizer.java Fri
Jul  9 00:22:18 2010
@@ -544,9 +544,10 @@ public class Tokenizer
                     value = ww;
                     Object expand = expand(value, evaluate, true);
 
-                    if (eot() && buf.length() == 0 && value.equals(expand))
+                    if (eot() && buf.length() == 0 && value == expand)
                     {
-                        return ww.value;
+                        // FELIX-2468 avoid returning CharSequence implementation
+                        return ww.value.toString();
                     }
 
                     if (null != expand)

Modified: felix/trunk/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/TestParser2.java
URL: http://svn.apache.org/viewvc/felix/trunk/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/TestParser2.java?rev=962374&r1=962373&r2=962374&view=diff
==============================================================================
--- felix/trunk/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/TestParser2.java
(original)
+++ felix/trunk/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/TestParser2.java
Fri Jul  9 00:22:18 2010
@@ -67,6 +67,8 @@ public class TestParser2 extends TestCas
     {
         Context c = new Context();
         c.addCommand("echo", this);
+        c.addCommand("new", this);
+        
         // FELIX-2433
         assertEquals("helloworld", c.execute("echo \"$(echo hello)world\""));
         
@@ -78,6 +80,11 @@ public class TestParser2 extends TestCas
             fail("expected: command not found: four");
         } catch (IllegalArgumentException e) {
         }
+        
+        // check CharSequence types are preserved
+        Object b = c.execute("b = new java.lang.StringBuilder");
+        assertTrue(b instanceof StringBuilder);
+        assertEquals(b, c.execute("c = $b"));
     }
 
     public CharSequence echo(Object args[])
@@ -96,5 +103,9 @@ public class TestParser2 extends TestCas
         }
         return sb.toString();
     }
+    
+    public Object _new(String className) throws Exception {
+        return Class.forName(className).newInstance();
+    }
 
 }



Mime
View raw message