com.fasterxml.jackson.databind.JsonMappingException: net.sf.json.JSONNull["empty"])

今天还没有上班,leader给了一个错误的预警,忙了一上午,发现就是数据库里多了一条脏数据。删了就OK了。

在本地调试的时候,报如下错误:

[2019-04-18 10:43:57.101] [http-nio-10399-exec-1] [org.springframework.web.servlet.mvc.supp
ort.DefaultHandlerExceptionResolver] [WARN] Failed to write HTTP message: org.springfra
mework.http.converter.HttpMessageNotWritableException: Could not write JSON: Object is
 null; nested exception is com.fasterxml.jackson.databind.JsonMappingException: Object
 is null (through reference chain: net.sf.json.JSONObject["vin"]->net.sf.json.JSONArr
 ay[4021]->net.sf.json.JSONNull["empty"]) 

 对错误进行分段后如下:

 [org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver] 
 [WARN] Failed to write HTTP message: 
 org.springframework.http.converter.HttpMessageNotWritableException: 
 Could not write JSON: Object is null; 
 nested exception is com.fasterxml.jackson.databind.JsonMappingException: 
 Object is null 
 (through reference chain: 
  net.sf.json.JSONObject["vin"]
 ->net.sf.json.JSONArray[4021]
 ->net.sf.json.JSONNull["empty"])


经过分析,这个错是程序中 
template.postForObject(redisSeondUrl + "showWarnInfoNevBuss",object,String.class)
这一步报的错,但是注意,这里并不是接口服务报错,而是这行命令本身报错。

最后发现 是因为vinList这个value中存在空字符串,本来vinList应该是["vin1","vin2","vin3","vin4"]
,结果发现vinList存在["vin1","vin2","","vin4"] 这样的情况(注意出现了空字符串)。 
导致在把object作为参数调用template的postForObject方法的时候,此方法报错了,程序无法继续执行。

程序中还有如下的关键步骤:

        object.put("vin", vinList);
        object.put("startDateTime", startDateTime);
        object.put("endDateTime", endDateTime);    

最后发现,是因为车辆表中存在一行问题数据,这行数据的vin是空的,导致查询的vinList含有空值导致故障。

最重要的是你要分析错误提示,即使不是完全明白,还是要努力的去看与分析其中蕴含的线索!

而且只是正式库报错,测试库不报,两个库中的车辆表的车辆信息不同,这也是找问题的一个关键突破口。

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值