You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@felix.apache.org by "Jason Dillon (JIRA)" <ji...@apache.org> on 2017/05/10 17:55:04 UTC
[jira] [Created] (FELIX-5639) Error thrown by Function gets gobbled
up
Jason Dillon created FELIX-5639:
-----------------------------------
Summary: Error thrown by Function gets gobbled up
Key: FELIX-5639
URL: https://issues.apache.org/jira/browse/FELIX-5639
Project: Felix
Issue Type: Bug
Components: Gogo Runtime
Reporter: Jason Dillon
Appears that if a registered function throws an java.lang.Error that something in gogo eats the throwable.
I hacked in a "error" function into the processor to help show this:
{noformat}
diff --git a/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/CommandProcessorImpl.java b/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/CommandProcessorImpl.java
index 451a1c8f0..b227d72c5 100644
--- a/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/CommandProcessorImpl.java
+++ b/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/CommandProcessorImpl.java
@@ -23,6 +23,7 @@ import java.io.OutputStream;
import java.lang.reflect.Method;
import java.util.Collections;
import java.util.LinkedHashMap;
+import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
@@ -147,6 +148,18 @@ public class CommandProcessorImpl implements CommandProcessor
String cfunction = name.substring(colon);
boolean anyScope = (colon == 1 && name.charAt(0) == '*');
+ // HACK: testing errors
+ System.out.println("NAME: " + name);
+ if (name.equals("*:error")) {
+ return new Function() {
+ @Override
+ public Object execute(CommandSession session, List<Object> arguments) throws Exception {
+ System.out.println("THROWING ERROR");
+ throw new Error("OOPS");
+ }
+ };
+ }
+
Map<Object, Integer> cmdMap = commands.get(name);
if (null == cmdMap && anyScope)
{noformat}
And then using the jline3 demo program tested:
{noformat}
g! error 14:27:05
NAME: *:error
THROWING ERROR
g!
{noformat}
After a quick chat with gnodet he mentioned perhaps:
{quote}
I think the swallowing happens here:
https://github.com/apache/felix/blob/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/CommandSessionImpl.java#L763-L769
However, I think the real place where the exception is thrown is there:
https://github.com/apache/felix/blob/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/CommandSessionImpl.java#L825
where ExecutionException should be caught and turned into a Result I think.
{quote}
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)