don't automatically convert return values that are arrays to ArrayList (FELIX-2337)
This makes the following just work:
g! headers (bundles)
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@949185 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Closure.java b/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Closure.java
index 724fcbb..72cb58b 100644
--- a/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Closure.java
+++ b/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Closure.java
@@ -21,7 +21,6 @@
import java.io.EOFException;
import java.util.AbstractList;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -220,17 +219,7 @@
Pipe.reset(mark); // reset IO in case same thread used for new client
- if (last == null)
- {
- return null;
- }
-
- if (last.result instanceof Object[])
- {
- return Arrays.asList((Object[]) last.result);
- }
-
- return last.result;
+ return last == null ? null : last.result;
}
public Object eval(final Token t) throws Exception
@@ -465,6 +454,12 @@
return Reflective.method(session, target, args.remove(0).toString(), args);
}
+ else if (cmd.getClass().isArray() && values.size() == 1)
+ {
+ Object[] cmdv = (Object[])cmd;
+ String index = values.get(0).toString();
+ return "length".equals(index) ? cmdv.length : cmdv[Integer.parseInt(index)];
+ }
else
{
return Reflective.method(session, cmd, values.remove(0).toString(), values);
@@ -489,7 +484,18 @@
List<Object> olist = new ArrayList<Object>();
for (Token t : list)
{
- olist.add(eval(t));
+ Object oval = eval(t);
+ if (oval.getClass().isArray())
+ {
+ for (Object o : (Object[])oval)
+ {
+ olist.add(o);
+ }
+ }
+ else
+ {
+ olist.add(oval);
+ }
}
return olist;
}