Skip to content

Commit

Permalink
Fix for loop reference test pass on protostuff (#3252)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bricks-Man authored and ralf0131 committed Jan 24, 2019
1 parent e07038b commit 33f1726
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,15 @@

package org.apache.dubbo.common.serialize.protostuff;

import org.apache.dubbo.common.serialize.ObjectInput;
import org.apache.dubbo.common.serialize.protostuff.utils.WrapperUtils;

import io.protostuff.ProtobufIOUtil;
import io.protostuff.GraphIOUtil;
import io.protostuff.Schema;
import io.protostuff.runtime.RuntimeSchema;

import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Type;
import org.apache.dubbo.common.serialize.ObjectInput;
import org.apache.dubbo.common.serialize.protostuff.utils.WrapperUtils;

/**
* Protostuff object input implementation
Expand Down Expand Up @@ -63,12 +61,12 @@ public Object readObject() throws IOException, ClassNotFoundException {
if (WrapperUtils.needWrapper(clazz)) {
Schema<Wrapper> schema = RuntimeSchema.getSchema(Wrapper.class);
Wrapper wrapper = schema.newMessage();
ProtobufIOUtil.mergeFrom(bytes, wrapper, schema);
GraphIOUtil.mergeFrom(bytes, wrapper, schema);
result = wrapper.getData();
} else {
Schema schema = RuntimeSchema.getSchema(clazz);
result = schema.newMessage();
ProtobufIOUtil.mergeFrom(bytes, result, schema);
GraphIOUtil.mergeFrom(bytes, result, schema);
}

return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,15 @@

package org.apache.dubbo.common.serialize.protostuff;

import org.apache.dubbo.common.serialize.ObjectOutput;
import org.apache.dubbo.common.serialize.protostuff.utils.WrapperUtils;

import io.protostuff.GraphIOUtil;
import io.protostuff.LinkedBuffer;
import io.protostuff.ProtobufIOUtil;
import io.protostuff.Schema;
import io.protostuff.runtime.RuntimeSchema;

import java.io.DataOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import org.apache.dubbo.common.serialize.ObjectOutput;
import org.apache.dubbo.common.serialize.protostuff.utils.WrapperUtils;

/**
* Protostuff object output implementation
Expand All @@ -52,11 +50,11 @@ public void writeObject(Object obj) throws IOException {
if (WrapperUtils.needWrapper(obj)) {
Schema<Wrapper> schema = RuntimeSchema.getSchema(Wrapper.class);
Wrapper wrapper = new Wrapper(obj);
bytes = ProtobufIOUtil.toByteArray(wrapper, schema, buffer);
bytes = GraphIOUtil.toByteArray(wrapper, schema, buffer);
classNameBytes = Wrapper.class.getName().getBytes();
} else {
Schema schema = RuntimeSchema.getSchema(obj.getClass());
bytes = ProtobufIOUtil.toByteArray(obj, schema, buffer);
bytes = GraphIOUtil.toByteArray(obj, schema, buffer);
classNameBytes = obj.getClass().getName().getBytes();
}
} finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,4 @@ public class ProtostuffSerializationTest extends AbstractSerializationTest {
serialization = new ProtostuffSerialization();
}

@Override
@Test
public void test_LoopReference() throws Exception {
// FIXME: cannot make this test pass on protostuff
}
}

0 comments on commit 33f1726

Please sign in to comment.