今天还没有上班,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含有空值导致故障。
最重要的是你要分析错误提示,即使不是完全明白,还是要努力的去看与分析其中蕴含的线索!
而且只是正式库报错,测试库不报,两个库中的车辆表的车辆信息不同,这也是找问题的一个关键突破口。