Skip to content

Commit

Permalink
fix hession bug
Browse files Browse the repository at this point in the history
  • Loading branch information
wangxiaobin authored and wxbty committed Feb 16, 2023
1 parent 0635a6a commit d4ffe85
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1329,23 +1329,15 @@ protected void writeRef(int value)
public boolean addRef(Object object)
throws IOException
{
if (_isUnshared) {
_refCount++;
return false;
}

int newRef = _refCount;
int ref = _refs.get(object);

int ref = addRef(object, newRef, false);

if (ref != newRef) {
if (ref >= 0) {
writeRef(ref);

return true;
}
else {
_refCount++;

} else {
_refs.put(object, _refs.size(),false);

return false;
}
}
Expand Down
12 changes: 12 additions & 0 deletions repeater-plugin-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,18 @@
<modelVersion>4.0.0</modelVersion>

<artifactId>repeater-plugin-core</artifactId>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>7</source>
<target>7</target>
</configuration>
</plugin>
</plugins>
</build>

<dependencies>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
package com.alibaba.jvm.sandbox.repeater.plugin.core.serialize;

import com.alibaba.jvm.sandbox.repeater.plugin.core.wrapper.SerializerWrapper;
import com.alibaba.jvm.sandbox.repeater.plugin.domain.MockInvocation;
import org.testng.Assert;
import org.testng.annotations.Test;

import java.util.ArrayList;
import java.util.GregorianCalendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
* {@link }
* <p>
Expand Down Expand Up @@ -41,4 +49,34 @@ public void deserialize() {
Assert.fail(e.getMessage());
}
}

@Test
public void serializeSpec() {
List<MockInvocation> list = new ArrayList<>();
MockInvocation m1 = new MockInvocation();
MockInvocation m2 = new MockInvocation();
list.add(m1);
list.add(m2);

Object[] org = new Object[1];
org[0] = new GregorianCalendar();
m1.setCurrentArgs(org);

Object xxx = new Object();

Map<String, Object> map = new HashMap<>();
map.put("xx", xxx);
map.put("jj", xxx);
Object[] ol = new Object[1];
ol[0] = map;
m2.setCurrentArgs(ol);

try {
String ens = SerializerWrapper.hessianSerialize(list);
SerializerWrapper.hessianDeserialize(ens);
} catch (SerializeException e) {
Assert.assertNull(e);
}
Assert.assertTrue(true);
}
}

0 comments on commit d4ffe85

Please sign in to comment.