【发布时间】:2019-08-07 14:13:08
【问题描述】:
有时我的 java/groovy 应用程序的行为很奇怪:有一个不为空且其中包含值的映射,但是当我尝试通过我在记录该映射时看到的完全相同的键获取值时为空。最奇怪的是log中的map有重复的key。
重新启动应用程序可以解决问题,但我感兴趣的是这怎么可能。
我有这个代码:
def mainField = typeSettings?.mainField != null
? typeSettings?.mainField
: classSettings.mainField
logger.info("${typeSettings}\n ${classSettings}\n ${classSettings.mainField}")
我确定classSettings 不是null
这是我在日志中看到的:
null
[
iconsField:[],
mainField:[
[
code:portalCard, showTitle:false, pages:[card]
],
[
code:portalAddForm, showTitle:false, pages:[addForm]
]
],
footer:[showNegotDate:true, showPlanDate:true],
footer:[showNegotDate:true, showPlanDate:true]
]
null
但很明显,mainField 存在于映射中,更重要的是,该映射中有两个重复的键 footer。
【问题讨论】: