QNJR-GROUP / EasyTransaction

A distribute transaction solution(分布式事务) unified the usage of TCC , SAGA ,FMT (seata/fescar AutoCompensation), reliable message, compensate and so on;
Apache License 2.0
2.36k stars 810 forks source link

消息实体类中包含java.sql.Date类型时报错 #47

Closed cimichen closed 6 years ago

cimichen commented 6 years ago

在消息消息实体类中包含java.sql.Date类型时,会有如下报错

Caused by: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
    at com.yiqiniu.easytrans.util.ObjectDigestUtil.getComlpexObjectOrderedString(ObjectDigestUtil.java:119)
    at com.yiqiniu.easytrans.util.ObjectDigestUtil.getObjectString(ObjectDigestUtil.java:97)
    at com.yiqiniu.easytrans.util.ObjectDigestUtil.getComlpexObjectOrderedString(ObjectDigestUtil.java:112)
    ... 2 more
Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.yiqiniu.easytrans.util.ObjectDigestUtil.getComlpexObjectOrderedString(ObjectDigestUtil.java:110)
    ... 4 more
Caused by: java.lang.IllegalArgumentException
    at java.sql.Date.getHours(Date.java:187)
    ... 9 more

原因是ObjectDigestUtil类中会利用反射去获取类的属性,而java.sql.Date类中getHours()、getMinutes()、getSeconds()都会直接throw new java.lang.IllegalArgumentException(),源代码如下:

@Deprecated
    public int getSeconds() {
        throw new java.lang.IllegalArgumentException();
    }

所以修改了ObjectDigestUtil类中的getObjectString方法,提交了一个Pull request,请查看

skyesx commented 6 years ago

THX