ClouGence / hasor

Hasor是一套基于 Java 语言的开发框架,区别于其它框架的是 Hasor 有着自己一套完整的体系,同时还可以和先有技术体系做到完美融合。它包含:IoC/Aop容器框架、Web框架、Jdbc框架、RSF分布式RPC框架、DataQL引擎,等几块。
http://www.hasor.net
Apache License 2.0
983 stars 273 forks source link

setupEnvironment 报NPE #80

Closed limboinf closed 3 years ago

limboinf commented 3 years ago

集成其他spring框架时如果环境变量值为null就报错

报错信息:

Caused by: java.lang.NullPointerException: null
    at java.util.Hashtable.put(Hashtable.java:460)
    at java.util.Hashtable.putAll(Hashtable.java:524)
    at net.hasor.spring.beans.AbstractEnvironmentAware.setupEnvironment(AbstractEnvironmentAware.java:47)
    at net.hasor.spring.beans.AbstractTypeSupplierTools.setEnvironment(AbstractTypeSupplierTools.java:47)
    at org.springframework.context.support.ApplicationContextAwareProcessor.invokeAwareInterfaces(ApplicationContextAwareProcessor.java:105)
    at org.springframework.context.support.ApplicationContextAwareProcessor.postProcessBeforeInitialization(ApplicationContextAwareProcessor.java:96)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:413)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1761)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:592)
    ... 85 common frames omitted

问题定位: AbstractEnvironmentAware类setupEnvironment方法, 对于propertySource.getSource() 如果map中value有null 则,putAll 报NEP。

// AbstractEnvironmentAware.setupEnvironment

if (source instanceof Map) {
    envProperties.putAll(((Map) source));
}

其他信息

版本:4.1.9

zycgit commented 3 years ago

确认有 NPE 问题,net.hasor:hasor-spring:4.1.9-fix20201201 提供了对应版本的临时解决方案。

并且合入尚在开发的 4.2.2 分支