Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix hession bug #201

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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);
}
}