Skip to content

Instantly share code, notes, and snippets.

@kenwdelong
Created November 17, 2015 20:32
Show Gist options
  • Save kenwdelong/72329d97ac0c0ac65afd to your computer and use it in GitHub Desktop.
Save kenwdelong/72329d97ac0c0ac65afd to your computer and use it in GitHub Desktop.
Script to Determine order of Servlet Filters in Spring application

A short Groovy script that you can use to filter out the noise from a stack trace to see what order the servlet filters are actually configured with.

A simple way to do this is throw a RuntimeException from a controller, hit that URL, and copy and paste the stack trace into the script below.

x is the stack trace
x.split('\n').findAll { it =~ /doFilter/ }
.findAll { !(it =~ /ApplicationFilterChain/)}
.findAll { !(it =~ /OncePerRequestFilter/)}
.findAll { !(it =~ /FilterChainProxy/)}
.collect {
def r
it.eachMatch(/at (.*)\.doFilter/) { match -> r = match[1]}
return r
}.each { println it }
println 'done'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment