diff --git a/bin/install-local.sh b/bin/install-local.sh index e7d7ee12..7a7e5f88 100755 --- a/bin/install-local.sh +++ b/bin/install-local.sh @@ -16,7 +16,7 @@ exit_on_err() sh ./package.sh || exit_on_err 1 "install failed cause package failed" # extract sandbox to ${HOME} -curl -s http://sandbox-ecological.oss-cn-hangzhou.aliyuncs.com/sandbox-1.2.1-bin.tar | tar xz -C ${HOME} || exit_on_err 1 "extract sandbox failed" +curl -s http://sandbox-ecological.oss-cn-hangzhou.aliyuncs.com/sandbox-1.3.3-bin.tar | tar xz -C ${HOME} || exit_on_err 1 "extract sandbox failed" # copy module to ~/.sandbox-module mkdir -p ${HOME}/.sandbox-module || exit_on_err 1 "permission denied, can not mkdir ~/.sandbox-module" diff --git a/bin/install-repeater.sh b/bin/install-repeater.sh index e07cf06e..ac71eca1 100755 --- a/bin/install-repeater.sh +++ b/bin/install-repeater.sh @@ -16,7 +16,7 @@ exit_on_err() main(){ echo "====== begin to install sandbox and repeater module ======"; echo "====== step 0 begin to download sandbox package ======"; - curl -s http://sandbox-ecological.oss-cn-hangzhou.aliyuncs.com/sandbox-1.2.1-bin.tar | tar xz -C ${HOME} || exit_on_err 1 "extract sandbox failed" + curl -s http://sandbox-ecological.oss-cn-hangzhou.aliyuncs.com/sandbox-1.3.3-bin.tar | tar xz -C ${HOME} || exit_on_err 1 "extract sandbox failed" echo "====== step 1 begin to download repeater module package ======"; if [ ! -d ${MODULE_HOME} ]; then mkdir -p ${MODULE_HOME} || exit_on_err 1 "permission denied mkdir ${MODULE_HOME}" diff --git a/bin/package.sh b/bin/package.sh index b21270d4..05f134cb 100755 --- a/bin/package.sh +++ b/bin/package.sh @@ -30,4 +30,11 @@ cp ./repeater-logback.xml ${REPEATER_TARGET_DIR}/cfg/repeater-logback.xml \ && cp ../repeater-plugins/redis-plugin/target/redis-plugin-*-jar-with-dependencies.jar ${REPEATER_TARGET_DIR}/plugins/redis-plugin.jar \ && cp ../repeater-plugins/http-plugin/target/http-plugin-*-jar-with-dependencies.jar ${REPEATER_TARGET_DIR}/plugins/http-plugin.jar \ && cp ../repeater-plugins/hibernate-plugin/target/hibernate-plugin-*-jar-with-dependencies.jar ${REPEATER_TARGET_DIR}/plugins/hibernate-plugin.jar \ - && cp ../repeater-plugins/spring-data-jpa-plugin/target/spring-data-jpa-plugin-*-jar-with-dependencies.jar ${REPEATER_TARGET_DIR}/plugins/spring-data-jpa-plugin.jar \ No newline at end of file + && cp ../repeater-plugins/spring-data-jpa-plugin/target/spring-data-jpa-plugin-*-jar-with-dependencies.jar ${REPEATER_TARGET_DIR}/plugins/spring-data-jpa-plugin.jar + +# tar the repeater.tar +cd ../target/ +tar -zcvf repeater-stable-bin.tar repeater/ +cd - + +echo "package repeater-stable-bin.zip finish." \ No newline at end of file diff --git a/hessian-lite/src/main/java/com/caucho/hessian/io/JavaSerializer.java b/hessian-lite/src/main/java/com/caucho/hessian/io/JavaSerializer.java index 8af0df85..518e3464 100644 --- a/hessian-lite/src/main/java/com/caucho/hessian/io/JavaSerializer.java +++ b/hessian-lite/src/main/java/com/caucho/hessian/io/JavaSerializer.java @@ -56,6 +56,7 @@ import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.util.ArrayList; +import java.util.Collections; import java.util.WeakHashMap; import java.util.logging.Level; import java.util.logging.Logger; @@ -141,7 +142,8 @@ protected void introspect(Class cl) ArrayList fields = new ArrayList(); fields.addAll(primitiveFields); fields.addAll(compoundFields); - + // 属性倒序,先写入父类属性,再写入子类属性,保证子类属性不被覆盖 + Collections.reverse(fields); _fields = new Field[fields.size()]; fields.toArray(_fields); diff --git a/hessian-lite/src/main/java/com/caucho/hessian/io/UnsafeSerializer.java b/hessian-lite/src/main/java/com/caucho/hessian/io/UnsafeSerializer.java index fd46f9ed..2059f3c7 100644 --- a/hessian-lite/src/main/java/com/caucho/hessian/io/UnsafeSerializer.java +++ b/hessian-lite/src/main/java/com/caucho/hessian/io/UnsafeSerializer.java @@ -56,6 +56,7 @@ import java.lang.reflect.Field; import java.lang.reflect.Modifier; import java.util.ArrayList; +import java.util.Collections; import java.util.WeakHashMap; import java.util.logging.Level; import java.util.logging.Logger; @@ -142,7 +143,8 @@ protected void introspect(Class cl) ArrayList fields = new ArrayList(); fields.addAll(primitiveFields); fields.addAll(compoundFields); - + // 属性倒序,先写入父类属性,再写入子类属性,保证子类属性不被覆盖 + Collections.reverse(fields); _fields = new Field[fields.size()]; fields.toArray(_fields); diff --git a/repeater-plugin-core/src/test/java/com/alibaba/jvm/sandbox/repeater/plugin/core/serialize/HessianSerializeDomain.java b/repeater-plugin-core/src/test/java/com/alibaba/jvm/sandbox/repeater/plugin/core/serialize/HessianSerializeDomain.java index 252e4006..b3ed0498 100644 --- a/repeater-plugin-core/src/test/java/com/alibaba/jvm/sandbox/repeater/plugin/core/serialize/HessianSerializeDomain.java +++ b/repeater-plugin-core/src/test/java/com/alibaba/jvm/sandbox/repeater/plugin/core/serialize/HessianSerializeDomain.java @@ -26,6 +26,8 @@ public BigDecimal getMoney() { return money; } + private String name = "parent"; + public void setMoney(BigDecimal money) { this.money = money; } @@ -54,6 +56,14 @@ public void setLocalDate(LocalDate localDate) { this.localDate = localDate; } + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + @Override public boolean equals(Object o) { if (this == o) return true; diff --git a/repeater-plugin-core/src/test/java/com/alibaba/jvm/sandbox/repeater/plugin/core/serialize/HessianSerializeDomainSub.java b/repeater-plugin-core/src/test/java/com/alibaba/jvm/sandbox/repeater/plugin/core/serialize/HessianSerializeDomainSub.java new file mode 100644 index 00000000..3496750a --- /dev/null +++ b/repeater-plugin-core/src/test/java/com/alibaba/jvm/sandbox/repeater/plugin/core/serialize/HessianSerializeDomainSub.java @@ -0,0 +1,22 @@ +package com.alibaba.jvm.sandbox.repeater.plugin.core.serialize; + +/** + * {@link HessianSerializeDomainSub} + *

+ * + * @author zhaoyb1990 + */ +public class HessianSerializeDomainSub extends HessianSerializeDomain { + + private String name = "son"; + + @Override + public String getName() { + return name; + } + + @Override + public void setName(String name) { + this.name = name; + } +} diff --git a/repeater-plugin-core/src/test/java/com/alibaba/jvm/sandbox/repeater/plugin/core/serialize/HessianSerializerTest.java b/repeater-plugin-core/src/test/java/com/alibaba/jvm/sandbox/repeater/plugin/core/serialize/HessianSerializerTest.java index caf67063..b42a7329 100644 --- a/repeater-plugin-core/src/test/java/com/alibaba/jvm/sandbox/repeater/plugin/core/serialize/HessianSerializerTest.java +++ b/repeater-plugin-core/src/test/java/com/alibaba/jvm/sandbox/repeater/plugin/core/serialize/HessianSerializerTest.java @@ -25,4 +25,20 @@ public void serialize() { Assert.fail(e.getMessage()); } } + + + @Test + public void deserialize() { + HessianSerializeDomainSub domain = new HessianSerializeDomainSub(); + Serializer serializer = SerializerProvider.instance().provide(Serializer.Type.HESSIAN); + String sequence; + try { + sequence = serializer.serialize2String(domain); + Assert.assertNotNull(sequence); + HessianSerializeDomainSub deserialize = serializer.deserialize(sequence, HessianSerializeDomainSub.class); + Assert.assertEquals(domain, deserialize); + } catch (SerializeException e) { + Assert.fail(e.getMessage()); + } + } } \ No newline at end of file