springcloud调用服务,传递实体类参数,实体类属性中有null值,报错问题

问题:

      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;
	}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

你认识小汐吗

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值