Details
-
Improvement
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.1-rc-2
-
None
-
None
-
Patch
Description
There is currently no way to modify the classes that are removed during the sanitization of a stack trace. The mechanism is hard-coded into StackTraceUtils.
This code will let various packages add tests in the form of a closure (can be done during static initialization). An example of a test, or filter:
//Removes stack trace elements where the class is part of the com.lilypepper.groovy package, or any subpackages.
static final Closure filter =
If the closure returns true, the classname is definitely included in the stack trace. If it returns false, the classname is definitely omitted from the stack trace. If it returns null, processing continues (defaults are set by StackTraceUtils).
Add the following code to org.codehaus.groovy.runtime.StackTraceUtils:
private static List<Closure> classFilters = new ArrayList<Closure>();
public static void addClassTest(Closure classFilter)
{ classFilters.add(classFilter); }Also, modify method to look like this:
public static boolean isApplicationClass(String className) {
for(Closure classFilter : classFilters)
{
Boolean result = (Boolean)classFilter.call(className);
if(result != null)
}
for (int i = 0; i < GROOVY_PACKAGES.length; i++) {
String groovyPackage = GROOVY_PACKAGES[i];
if (className.startsWith(groovyPackage))
}
return true;
}