StackTraceUtils printSanitizedStackTrace does not print the same as sanitize

Merlin Beedell <[email protected]> Wed, 19 Feb 2025 13:33:03 +0000
Newsgroups gmane.comp.lang.groovy.user
Message-ID <LO0P123MB420130B6C5FB7313C119FBDBB9C52@LO0P123MB4201.GBRP123.PROD.OUTLOOK.COM>
Just testing out this handy sounding utility: StackTraceUtils.

First, the printSanitizedStackTrace does not print the same as the remaining trace after the sanitize method.  What is it meant to print?
Second, the StackTraceUtils.addClassTest is obviously global - but there does not seem to be a way to clear or modify the test list.  Perhaps not important - but when playing with the method in groovyConsole it simply keeps adding to the previous tests!

Test example...

...some errorble code here...
} catch(e) {
 println e
//  e.printStackTrace()  //uncomment to see the whole stack

 println 'sanitized 1'
//  PrintWriter writer = new PrintWriter(System.out);
//  StackTraceUtils.printSanitizedStackTrace(e, writer) //this outputs nothing
 StackTraceUtils.printSanitizedStackTrace(e)  //this prints nothing too

 println 'sanitized 2'
 StackTraceUtils.sanitize(e)
 e.printStackTrace()  //this is good, and prints the expected non-groovy stack
}

Merlin Beedell