filterInterceptor.handlers 升级到 spring 3.1.2 后

filterInterceptor.handlers after upgrade to spring 3.1.2

我升级到 Grails 3.0.17 和 Spring 3.1.2。我有这些错误

ERROR grails.boot.GrailsApp - Application startup failed
java.lang.ArrayIndexOutOfBoundsException: -1
        at java.util.ArrayList.elementData(ArrayList.java:422) ~[na:1.8.0_241]
        at java.util.ArrayList.remove(ArrayList.java:499) ~[na:1.8.0_241]
        at java_util_List$remove.call(Unknown Source) ~[na:na]
        at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48) [groovy-2.4.5.jar:2.4.5]
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113) [groovy-2.4.5.jar:2.4.5]
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125) [groovy-2.4.5.jar:2.4.5]
 at BootStrap.renderResponseFiltersMustBeLastInPipeLine(BootStrap.groovy:34) ~[main/:na]

部分代码BootStrap.groovy

 def filterInterceptor

    def init = { servletContext ->

        println "Initializing iMedCom client server"

        def applicationContext = grailsApplication.mainContext
        configureDatasource(applicationContext)
        renderResponseFiltersMustBeLastInPipeLine(filterInterceptor.handlers)

    }

    private renderResponseFiltersMustBeLastInPipeLine(allFilters) {
        def index = allFilters.findIndexOf {it.filterConfig.name == 'renderResponse'}
        def filter = allFilters.remove(index)
        allFilters.add(0, filter)
    }

在我的 application.groovy

grails.plugin.springsecurity.filterChain.chainMap = [
        [pattern: '/currentVersion',            filters: 'nonAuthFilter'],
        [pattern: '/patient-api.html',            filters: 'nonAuthFilter'],
        [pattern: '/isAlive',            filters: 'nonAuthFilter'],
        [pattern: '/isAlive/json',            filters: 'nonAuthFilter'],
        [pattern: '/isAlive/html',            filters: 'nonAuthFilter'],
        [pattern: '/**',            filters: 'JOINED_FILTERS,-exceptionTranslationFilter,-sessionManagementFilter,-rememberMeAuthenticationFilter,-authenticationProcessingFilter,-securityContextPersistenceFilter']
]

有什么想法吗?

以下是帮助我解决此问题的方法:

我替换了def index = allFilters.findIndexOf {it.filterConfig.name == 'renderResponse'}def index = allFilters.findAll{it.filterConfig.name == 'renderResponse'} 希望这对社区中的某个人有所帮助。