|
If possible, please provide an entry to access the original full stacktrace to report bug
Agreed Daniel. With the -d flag (d for debug), we should be allowed to see the full stacktrace.
I'm not really sure what else that can be easily trimmed out of the stack traces... I've already trimmed things up to the groovysh_evaluate.run invocation. And ya, you should see the full traces when --debug is set.
Several packages should be filtered by default:
groovy.*/* I lifted the sanitize stack trace stuff from grails and moved it into org.codehaus.groovy.runtime.StackTraceUtils, I am using it in GroovyConsole.
Just updated the defaults to reflect Guillaume's default. The defaults can be changed by setting the system property "groovy.sanitized.stacktraces" to a comma/whitespace separated list of class prefixes (no globbing or regexing, not that advanced). This hast to be done before the class is loaded however. I tried looking into getting this added to new shell, but ran out of time and the fix in console was working. I'm not sure that it is a good idea to filter these packages... since sometimes exceptions come from classes in those packages, which ends up producing quite unusable stack traces.
In the Groovy console I address that issue via View->Show Full Stack Traces. Perhaps a prefs could be set to sanitize? "\= show-full-stack".
Also, when a stack trace is sanitized the throwable is logged first to the 'StackTrace' logger. You could add a log listener, clone the throwables and store them in ' _ ' as the "return value". This allows the user to '_ .printStackTrace()' to get the full stack if it is confusing. If you do a deep sanitize you may want to catch only the first one per iteration. Ya, I think it should be fine add a preference to show the full stack.... I will look at StackTraceUtils and see how I can use it in groovysh.
StackTraceUtils looks good... except its spitting out logging crap, which makes the output even harder to grok... I think we need to remove that logging in StackTraceUtils... and then I'm happy happy to add this.
Um... I think I'm just gonna rip out that logging... if someone is using StackTraceUtils and they are worried about losing trace data, they should either log it themselves... or not use StackTraceUtils.
I'm gonna hook this up and use the sanitize-stack-trace preference (ala \=) to flip it on or off. And when --verbose is set, then it will override, so they always get the non-sanitize stack trace. Will that work for everyone? I've hooked up StackTraceUtils to sanitize the stack trace by default. Lemme know if there is more filtering/sanitization you want to see.
Cool, I'll try this out.
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||
C:\Documents and Settings\Guillaume Laforge>groovysh
0):000> import static java.lang.Math.*
0):000> random()
0):000> c = { random() }
0):000>
Groovy Shell (1.1-beta-3, JVM: 1.6.0_02-b06)
Type 'help' or '\h' for help.
-------------------------------------------------------------------------------------------------------------
groovy
groovy
001> random()
===> 0.35025511331429426
groovy
001> c = { random() }
ERROR groovy.lang.MissingMethodException: No signature of method: groovysh_evaluate.random() is applicable for
argument types: () values: {}
at groovy.lang.MetaClassImpl.invokeMissingMethod (MetaClassImpl.java:574)
at groovy.lang.MetaClassImpl.invokeMissingMethod (MetaClassImpl.java:545)
at groovy.lang.MetaClassImpl.invokeMethod (MetaClassImpl.java:787)
at groovy.lang.MetaClassImpl.invokeMethod (MetaClassImpl.java:614)
at groovy.lang.MetaClassImpl.invokeMethod (MetaClassImpl.java:537)
at groovy.lang.GroovyObjectSupport.invokeMethod (GroovyObjectSupport.java:44)
at groovy.lang.Script.invokeMethod (Script.java:78)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeOnDelegationObjects (ClosureMetaClass.
java:326)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod (ClosureMetaClass.java:287)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnCurrentN (ScriptBytecodeAdapter.jav
a:66)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnCurrent0 (ScriptBytecodeAdapter.jav
a:99)
at groovysh_evaluate$_run_closure1.doCall (groovysh_evaluate:2)
at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke (Method.java:597)
at org.codehaus.groovy.runtime.metaclass.ReflectionMetaMethod.invoke (ReflectionMetaMethod.java:64)
at org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke (MetaClassHelper.java:537)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod (ClosureMetaClass.java:224)
at groovy.lang.MetaClassImpl.invokeMethod (MetaClassImpl.java:614)
at groovy.lang.Closure.call (Closure.java:292)
at groovy.lang.GString.writeTo (GString.java:155)
at groovy.lang.GString.toString (GString.java:133)
at org.codehaus.groovy.reflection.CachedClass.coerceGString (CachedClass.java:95)
at org.codehaus.groovy.reflection.ParameterTypes.coerceArgumentsToClasses (ParameterTypes.java:92)
at org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke (MetaClassHelper.java:535)
at groovy.lang.MetaClassImpl.invokeMethod (MetaClassImpl.java:772)
at groovy.lang.MetaClassImpl.invokeMethod (MetaClassImpl.java:614)
at org.codehaus.groovy.runtime.Invoker.invokePojoMethod (Invoker.java:87)
at org.codehaus.groovy.runtime.Invoker.invokeMethod (Invoker.java:75)
at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod (InvokerHelper.java:74)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN (ScriptBytecodeAdapter.java:158)
at org.codehaus.groovy.tools.shell.Groovysh.setLastResult (Groovysh.groovy:92)
at org.codehaus.groovy.tools.shell.Groovysh.this$3$setLastResult (Groovysh.groovy)
at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke (Method.java:597)
at org.codehaus.groovy.runtime.metaclass.ReflectionMetaMethod.invoke (ReflectionMetaMethod.java:64)
at org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke (MetaClassHelper.java:537)
at groovy.lang.MetaClassImpl.setProperty (MetaClassImpl.java:1764)
at groovy.lang.MetaClassImpl.setProperty (MetaClassImpl.java:2412)
at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke (Method.java:597)
at org.codehaus.groovy.runtime.metaclass.ReflectionMetaMethod.invoke (ReflectionMetaMethod.java:64)
at org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke (MetaClassHelper.java:537)
at groovy.lang.MetaClassImpl.invokeMethod (MetaClassImpl.java:772)
at groovy.lang.MetaClassImpl.invokeMethod (MetaClassImpl.java:614)
at org.codehaus.groovy.runtime.Invoker.invokePojoMethod (Invoker.java:87)
at org.codehaus.groovy.runtime.Invoker.invokeMethod (Invoker.java:75)
at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod (InvokerHelper.java:74)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN (ScriptBytecodeAdapter.java:158)
at org.codehaus.groovy.tools.shell.Shell.setProperty (Shell.groovy)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.setGroovyObjectProperty (ScriptBytecodeAdapter.ja
va:571)
at org.codehaus.groovy.tools.shell.Groovysh.execute (Groovysh.groovy:182)
at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke (Method.java:597)
at org.codehaus.groovy.runtime.metaclass.ReflectionMetaMethod.invoke (ReflectionMetaMethod.java:64)
at org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke (MetaClassHelper.java:537)
at groovy.lang.MetaClassImpl.invokeMethod (MetaClassImpl.java:772)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnCurrentN (ScriptBytecodeAdapter.jav
a:66)
at org.codehaus.groovy.tools.shell.Shell.leftShift (Shell.groovy:121)
at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke (Method.java:597)
at org.codehaus.groovy.runtime.metaclass.ReflectionMetaMethod.invoke (ReflectionMetaMethod.java:64)
at org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke (MetaClassHelper.java:537)
at groovy.lang.MetaClassImpl.invokeMethod (MetaClassImpl.java:772)
at groovy.lang.MetaClassImpl.invokeMethod (MetaClassImpl.java:614)
at org.codehaus.groovy.runtime.Invoker.invokePogoMethod (Invoker.java:98)
at org.codehaus.groovy.runtime.Invoker.invokeMethod (Invoker.java:79)
at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod (InvokerHelper.java:74)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN (ScriptBytecodeAdapter.java:158)
at org.codehaus.groovy.tools.shell.ShellRunner.work (ShellRunner.groovy:88)
at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke (Method.java:597)
at org.codehaus.groovy.runtime.metaclass.ReflectionMetaMethod.invoke (ReflectionMetaMethod.java:64)
at org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke (MetaClassHelper.java:537)
at groovy.lang.MetaClassImpl.invokeMethod (MetaClassImpl.java:772)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnCurrentN (ScriptBytecodeAdapter.jav
a:66)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnCurrent0 (ScriptBytecodeAdapter.jav
a:99)
at org.codehaus.groovy.tools.shell.ShellRunner.run (ShellRunner.groovy:57)
at org.codehaus.groovy.tools.shell.InteractiveShellRunner.super$2$run (InteractiveShellRunner.groovy)
at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke (Method.java:597)
at org.codehaus.groovy.runtime.metaclass.ReflectionMetaMethod.invoke (ReflectionMetaMethod.java:64)
at org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke (MetaClassHelper.java:537)
at groovy.lang.MetaClassImpl.invokeMethod (MetaClassImpl.java:772)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnSuperN (ScriptBytecodeAdapter.java:
118)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnSuper0 (ScriptBytecodeAdapter.java:
142)
at org.codehaus.groovy.tools.shell.InteractiveShellRunner.run (InteractiveShellRunner.groovy:64)
at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke (Method.java:597)
at org.codehaus.groovy.runtime.metaclass.ReflectionMetaMethod.invoke (ReflectionMetaMethod.java:64)
at org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke (MetaClassHelper.java:537)
at groovy.lang.MetaClassImpl.invokeMethod (MetaClassImpl.java:772)
at groovy.lang.MetaClassImpl.invokeMethod (MetaClassImpl.java:614)
at org.codehaus.groovy.runtime.Invoker.invokePogoMethod (Invoker.java:98)
at org.codehaus.groovy.runtime.Invoker.invokeMethod (Invoker.java:79)
at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod (InvokerHelper.java:74)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN (ScriptBytecodeAdapter.java:158)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethod0 (ScriptBytecodeAdapter.java:201)
at org.codehaus.groovy.tools.shell.Groovysh.run (Groovysh.groovy:446)
at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke (Method.java:597)
at org.codehaus.groovy.runtime.metaclass.ReflectionMetaMethod.invoke (ReflectionMetaMethod.java:64)
at org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke (MetaClassHelper.java:537)
at groovy.lang.MetaClassImpl.invokeMethod (MetaClassImpl.java:772)
at groovy.lang.MetaClassImpl.invokeMethod (MetaClassImpl.java:614)
at org.codehaus.groovy.runtime.Invoker.invokePogoMethod (Invoker.java:98)
at org.codehaus.groovy.runtime.Invoker.invokeMethod (Invoker.java:79)
at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod (InvokerHelper.java:74)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN (ScriptBytecodeAdapter.java:158)
at org.codehaus.groovy.tools.shell.Groovysh.main (Groovysh.groovy:591)
at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke (Method.java:597)
at org.codehaus.groovy.tools.GroovyStarter.rootLoader (GroovyStarter.java:101)
at org.codehaus.groovy.tools.GroovyStarter.main (GroovyStarter.java:130)
groovy