NPE SpringLookupInitializer createLookup Spring Vaadin 19+;
在尝试更新到最新版本的Vaadin(问题时为20)时,由于SpringLookupInitializer中的NPE,我的应用程序将无法启动。当我使用Vaadin 19时,SpringLookupInitializer第一次被使用,我第一次遇到错误,我必须始终使用SpringVaadin 12.4.0来启动应用程序。错误似乎来自此更改 在12.4.0中,SpringLookupInitializer中的代码定义为:NPE SpringLookupInitializer createLookup Spring Vaadin 19+;,spring,vaadin,vaadin-flow,Spring,Vaadin,Vaadin Flow,在尝试更新到最新版本的Vaadin(问题时为20)时,由于SpringLookupInitializer中的NPE,我的应用程序将无法启动。当我使用Vaadin 19时,SpringLookupInitializer第一次被使用,我第一次遇到错误,我必须始终使用SpringVaadin 12.4.0来启动应用程序。错误似乎来自此更改 在12.4.0中,SpringLookupInitializer中的代码定义为: @Override protected Lookup create
@Override
protected Lookup createLookup(VaadinContext context,
Map<Class<?>, Collection<Class<?>>> services) {
WebApplicationContext appContext = getApplicationContext(context);
return new SpringLookup(appContext,
(spi, impl) -> instantiate(appContext, spi, impl), services);
}
private WebApplicationContext getApplicationContext(VaadinContext context) {
VaadinServletContext servletContext = (VaadinServletContext) context;
WebApplicationContext appContext = WebApplicationContextUtils
.getWebApplicationContext(servletContext.getContext());
if (appContext == null) {
// Spring behavior is always unbelievably surprising: under some
// circumstances {@code appContext} may be null even though the app
// context has been set via ApplicationContextAware: no idea WHY
ApplicationContextWrapper wrapper = context
.getAttribute(ApplicationContextWrapper.class);
appContext = wrapper == null ? null : wrapper.appContext;
}
return appContext;
}
@覆盖
受保护的查找createLookup(VaadinContext上下文,
地图>>服务){
WebApplicationContext-appContext=getApplicationContext(上下文);
返回新的SpringLookup(appContext,
(spi,impl)->实例化(appContext,spi,impl),服务;
}
私有WebApplicationContext getApplicationContext(VaadinContext上下文){
VaadinServletContext servletContext=(VaadinServletContext)上下文;
WebApplicationContext appContext=WebApplicationContext
.getWebApplicationContext(servletContext.getContext());
if(appContext==null){
//春天的行为总是令人难以置信地惊讶:在某些情况下
//即使应用程序
//上下文已通过ApplicationContextAware设置:不知道为什么
ApplicationContextWrapper=上下文
.getAttribute(ApplicationContextWrapper.class);
appContext=wrapper==null?null:wrapper.appContext;
}
返回appContext;
}
它是这样工作的,因为它正在进行检查并在继续之前更正它(基本上是评论所说的)。在最新版本中,getApplicationContext被删除,不再执行检查
@Override
protected Lookup createLookup(VaadinContext context,
Map<Class<?>, Collection<Class<?>>> services) {
WebApplicationContext appContext = WebApplicationContextUtils
.getWebApplicationContext(
((VaadinServletContext) context).getContext());
return new SpringLookup(appContext,
(spi, impl) -> instantiate(appContext, spi, impl), services);
}
@覆盖
受保护的查找createLookup(VaadinContext上下文,
地图>>服务){
WebApplicationContext appContext=WebApplicationContext
.getWebApplicationContext(
((VaadinServletContext)context.getContext());
返回新的SpringLookup(appContext,
(spi,impl)->实例化(appContext,spi,impl),服务;
}
我不使用SpringBoot,只使用MVC,使用旧的SpringVaadin版本,一切都很好。是否有一个原因,它不再执行此检查或其他已实现的操作,我可以这样做来阻止这种情况发生
感谢感谢您的报告-似乎在最新版本的Vaadin Spring附加组件中忽略了这些更改(在PR中)。我们正在经历这些变化,并确保这些得到提前移植,并将很快为瓦丁20发布 对于类似的情况,当更新Vaadin版本时,建议直接将新版本打开到相应的存储库(如or),以便开发团队立即注意到。谢谢
编辑:修复程序已在中发布。您可以指定项目显式使用该版本的
vaadin-spring
工件。它将包含在最迟于6月14日下周一发布的Vaadin 20.0.2版本中。作为参考,新的cherry pick: