提交 6f1d0fce 编写于 作者: K kimi

DUBBO-342 改进计算 hash code 的方法

git-svn-id: http://code.alibabatech.com/svn/dubbo/trunk@1583 1a56cb94-b969-4eaa-88fa-be21384802f2
上级 482c68c0
...@@ -110,7 +110,7 @@ public class PojoUtils { ...@@ -110,7 +110,7 @@ public class PojoUtils {
return ((Class)pojo).getName(); return ((Class)pojo).getName();
} }
Integer id = System.identityHashCode(pojo); Integer id = hashCode(pojo);
if (history.containsKey(id)) { if (history.containsKey(id)) {
return history.get(id); return history.get(id);
} }
...@@ -227,7 +227,7 @@ public class PojoUtils { ...@@ -227,7 +227,7 @@ public class PojoUtils {
private static Object realize1(Object pojo, Class<?> type, final Map<Integer, Object> history) { private static Object realize1(Object pojo, Class<?> type, final Map<Integer, Object> history) {
return realize0(pojo, type, null , history); return realize0(pojo, type, null , history);
} }
@SuppressWarnings({ "unchecked", "rawtypes" }) @SuppressWarnings({ "unchecked", "rawtypes" })
private static Object realize0(Object pojo, Class<?> type, Type genericType, final Map<Integer, Object> history) { private static Object realize0(Object pojo, Class<?> type, Type genericType, final Map<Integer, Object> history) {
if (pojo == null) { if (pojo == null) {
...@@ -473,4 +473,7 @@ public class PojoUtils { ...@@ -473,4 +473,7 @@ public class PojoUtils {
&& ! Map.class.isAssignableFrom(cls); && ! Map.class.isAssignableFrom(cls);
} }
private static int hashCode(Object object) {
return 31 * (object.getClass().getName().hashCode() ^ System.identityHashCode(object));
}
} }
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册