Description
Toshiaki Maki opened SPR-15219 and commented
Router functions are actually available without ApplicationContext
for very small footprint applications, but UrlBasedViewResolver
calls getApplicationContext().getAutowireCapableBeanFactory()
.
This causes NullPointerException
if i use router functions and freemaker without ApplicationContext
.
private View applyLifecycleMethods(String viewName, AbstractView view) {
return (View) getApplicationContext().getAutowireCapableBeanFactory().initializeBean(view, viewName);
}
I'd be happy if these are decoupled.
Easiest way might be using lifecycleMethods
as a BiFunction
like following:
private BiFunction<String, AbstractView, View> lifecycleMethods = (viewName,
view) -> (View) getApplicationContext().getAutowireCapableBeanFactory()
.initializeBean(view, viewName);
public void setLifecycleMethods(
BiFunction<String, AbstractView, View> lifecycleMethods) {
this.lifecycleMethods = lifecycleMethods;
}
private View applyLifecycleMethods(String viewName, AbstractView view) {
return lifecycleMethods.apply(viewName, view);
}
I'm using this hack as a workarround.
https://github.com/making/ik.am/tree/622b1c289ea4273210d4bc0a1a905fa890e8b1b7/src/main/java/am/ik/FreeMarkerConfig.java
https://github.com/making/ik.am/blob/622b1c289ea4273210d4bc0a1a905fa890e8b1b7/src/main/java/org/springframework/web/reactive/result/view/UrlBasedViewResolver.java
Affects: 5.0 M4
Issue Links:
- Introduce null-safety of Spring Framework API [SPR-15540] #20099 Introduce null-safety of Spring Framework API
- AOP and use of redirect view can lead to unbounded caching in AbstractAutoProxyCreator [SPR-17045] #21583 AOP and use of redirect view can lead to unbounded caching in AbstractAutoProxyCreator
Referenced from: commits 14161d1
1 votes, 3 watchers