zrlw commented on issue #38:
URL:
https://github.com/apache/dubbo-hessian-lite/issues/38#issuecomment-3283169884
it seemed that ```java.io.EOFException``` will be thrown by current
hessian2, no matter using Integer[] or List<Integer>,
```
import com.alibaba.com.caucho.hessian.io.Hessian2Input;
import com.alibaba.com.caucho.hessian.io.Hessian2Output;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class Test {
public static void main(String[] args) throws IOException {
// DemoData data = new DemoData();
//
// List<Integer[]> list = new ArrayList<>();
// list.add(new Integer[]{1, 2, 3});
// list.add(new Integer[]{4, 5, 6});
// data.setList(list);
//
// data.setInts(new Integer[]{7, 8, 9});
DemoDataList data = new DemoDataList();
List<List<Integer>> list = new ArrayList<>();
list.add(Arrays.asList(1, 2, 3));
list.add(Arrays.asList(4, 5, 6));
data.setList(list);
data.setInts(Arrays.asList(7, 8, 9));
ObjectMapper objectMapper = new ObjectMapper();
String json = objectMapper.writeValueAsString(data);
System.out.println(json);
ByteArrayOutputStream out = new ByteArrayOutputStream();
Hessian2Output output = new Hessian2Output(out);
output.writeObject(data);
ByteArrayInputStream is = new
ByteArrayInputStream(out.toByteArray());
Hessian2Input input = new Hessian2Input(is);
Object o = input.readObject();
System.out.println(o);
json = objectMapper.writeValueAsString(o);
System.out.println(json);
}
}
class DemoData implements Serializable {
Integer[] ints;
List<Integer[]> list;
public Integer[] getInts() {
return ints;
}
public void setInts(Integer[] ints) {
this.ints = ints;
}
public List<Integer[]> getList() {
return list;
}
public void setList(List<Integer[]> list) {
this.list = list;
}
}
class DemoDataList implements Serializable {
List<Integer> ints;
List<List<Integer>> list;
public List<Integer> getInts() {
return ints;
}
public void setInts(List<Integer> ints) {
this.ints = ints;
}
public List<List<Integer>> getList() {
return list;
}
public void setList(List<List<Integer>> list) {
this.list = list;
}
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]