问题:
spring cloud方式调用接口,参数中有一个UserInfo对象,其中updateTime属性为空,然后再被调用方用了一个另外一个UserInfo对象接收,在set方法中使用了updateTime.clone()方法,因为接收对象反序列化的时候set值updateTime为空,在调用方出现调用异常如下:
Request","exception":"org.springframework.http.converter.HttpMessageNotReadableException","message":"JSON parse error: null; nested exception is com.fasterxml.jackson.databind.JsonMappingException: N/A\n at [Source: java.io.PushbackInputStream@45729515; line: 1, column: 361] (through reference chain: com.jd.jr.code.entity.UserInfo[\"updateTime\"])","path":"/v1.0/git/auth"}
18-08-14.09:44:13.848 [http-nio-8000-exec-3] ERROR GitRepositoryAuthController - 添加git仓库成员失败!
feign.FeignException: status 400 reading GitAuthWSService#gitAuthAdd(Long,String,String,String,UserInfo); content:
{"timestamp":1534211053846,"status":400,"error":"Bad Request","exception":"org.springframework.http.converter.HttpMessageNotReadableException","message":"JSON parse error: null; nested exception is com.fasterxml.jackson.databind.JsonMappingException: N/A\n at [Source: java.io.PushbackInputStream@45729515; line: 1, column: 361] (through reference chain: com.jd.jr.code.entity.UserInfo[\"updateTime\"])","path":"/v1.0/git/auth"}
at feign.FeignException.errorStatus(FeignException.java:62)
at feign.codec.ErrorDecoder$Default.decode(ErrorDecoder.java:91)
at feign.SynchronousMethodHandler.executeAndDecode(SynchronousMethodHandler.java:138)
at feign.SynchronousMethodHandler.invoke(SynchronousMethodHandler.java:76)
at feign.ReflectiveFeign$FeignInvocationHandler.invoke(ReflectiveFeign.java:103)
at com.sun.proxy.$Proxy98.gitAuthAdd(Unknown Source)
提示updateTime有问题;
解决办法:
将接收方UserInfo对象中的get/set方法改为如下即可
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}