You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I get a null pointer exception. By the time of access I can see that the factory field is set in SpringWroFilter, but not the wroManagerFactory in the base class WroFilter.
11:11:44.426 WEB [] DEBUG ro.isdc.wro.http.WroFilter - Exception occured
java.lang.NullPointerException: The validated object is null
at org.apache.commons.lang3.Validate.notNull(Validate.java:222) ~[commons-lang3-3.1.jar:3.1]
at org.apache.commons.lang3.Validate.notNull(Validate.java:203) ~[commons-lang3-3.1.jar:3.1]
at ro.isdc.wro.model.group.processor.InjectorBuilder.(InjectorBuilder.java:77) ~[wro4j-core-1.7.1.jar:1.7.1]
at ro.isdc.wro.model.group.processor.InjectorBuilder.create(InjectorBuilder.java:69) ~[wro4j-core-1.7.1.jar:1.7.1]
at ro.isdc.wro.http.WroFilter.getInjector(WroFilter.java:319) ~[wro4j-core-1.7.1.jar:1.7.1]
at ro.isdc.wro.http.WroFilter.handledWithRequestHandler(WroFilter.java:302) ~[wro4j-core-1.7.1.jar:1.7.1]
at ro.isdc.wro.http.WroFilter.doFilter(WroFilter.java:269) ~[wro4j-core-1.7.1.jar:1.7.1]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) [catalina.jar:7.0.39.B]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) [catalina.jar:7.0.39.B]
Looking at the code I can see why this happens. WroFilter init() function calls createWroManagerFactory() and in turn call the overridden newWroManagerFactory(). It subsequently calls the overridden doInit() function -- it is only at this point that the factory field will be set. By then it is too late.
Given the use of the final keyword on the servlet filter init() method, I can see no way to resolve this in SpringWroFilter itself. A hook needs to be added at the beginning of the init method or else the final keyword removed, so that SpringWroFilter can do its job before newWroManagerFactory() is called. Since the API needs to change and I don't know what the preference would be, I haven't made a pull request for it.
Rather, I sneaked in a fix with this awful hack. newWroConfigurationFactory can be overridden and gets access to filterConfig before newWroManagerFactory() is called.
To speed up the fix of this issue, it would be helpful to have an unit test which proves the problem or a quick start project with the configuration which is expected to work but doesn't.
I get a null pointer exception. By the time of access I can see that the factory field is set in SpringWroFilter, but not the wroManagerFactory in the base class WroFilter.
11:11:44.426 WEB [] DEBUG ro.isdc.wro.http.WroFilter - Exception occured
java.lang.NullPointerException: The validated object is null
at org.apache.commons.lang3.Validate.notNull(Validate.java:222) ~[commons-lang3-3.1.jar:3.1]
at org.apache.commons.lang3.Validate.notNull(Validate.java:203) ~[commons-lang3-3.1.jar:3.1]
at ro.isdc.wro.model.group.processor.InjectorBuilder.(InjectorBuilder.java:77) ~[wro4j-core-1.7.1.jar:1.7.1]
at ro.isdc.wro.model.group.processor.InjectorBuilder.create(InjectorBuilder.java:69) ~[wro4j-core-1.7.1.jar:1.7.1]
at ro.isdc.wro.http.WroFilter.getInjector(WroFilter.java:319) ~[wro4j-core-1.7.1.jar:1.7.1]
at ro.isdc.wro.http.WroFilter.handledWithRequestHandler(WroFilter.java:302) ~[wro4j-core-1.7.1.jar:1.7.1]
at ro.isdc.wro.http.WroFilter.doFilter(WroFilter.java:269) ~[wro4j-core-1.7.1.jar:1.7.1]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) [catalina.jar:7.0.39.B]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) [catalina.jar:7.0.39.B]
Looking at the code I can see why this happens. WroFilter init() function calls createWroManagerFactory() and in turn call the overridden newWroManagerFactory(). It subsequently calls the overridden doInit() function -- it is only at this point that the factory field will be set. By then it is too late.
Given the use of the final keyword on the servlet filter init() method, I can see no way to resolve this in SpringWroFilter itself. A hook needs to be added at the beginning of the init method or else the final keyword removed, so that SpringWroFilter can do its job before newWroManagerFactory() is called. Since the API needs to change and I don't know what the preference would be, I haven't made a pull request for it.
Rather, I sneaked in a fix with this awful hack. newWroConfigurationFactory can be overridden and gets access to filterConfig before newWroManagerFactory() is called.
Grotesque -- we need an API change to WroFilter().
The text was updated successfully, but these errors were encountered: