-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
关于Page.records默认值的问题 #6263
Comments
虽然可以修改成普通的ArrayList,但这大概率也可以通过升级fastjson解决. |
fastjson已经是最新版本了 |
不确定是不是些这样的问题. |
看issue里描述是同一个问题,我看看fastjson2那边能不能解决吧 |
拿fastjson的代码验证了一下,只有存在属性为public的情况才能复现这个情况,不确定是否为同个情况,需要补充复现工程来看看. |
你的响应模型是自定义的还是直接PageDto? public class App {
public static void main(String[] args) {
Page<Person> page = new Page<>();
List<Person> data = new ArrayList<>();
data.add(null);
data.add(new Person("abc"));
data.add(null);
// page.data = Collections.unmodifiableList(data);
page.setData(data);
byte[] bytes = JSONB.toBytes(page);
Page page1 = JSONB.parseObject(bytes, Page.class);
System.out.println(page1);
}
public static class Person {
private String name;
public Person() {
}
public Person(String name) {
this.name = name;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
public static class Page<T> {
// 属性为public下才会出问题.
public List<T> data = Collections.emptyList();
public void setData(List<T> items) {
this.data = items;
}
public List<T> getData() {
return data;
}
}
} |
@nieqiurong https://github.com/Alleninggx/MybatisPlus-test 改一下redis地址,先启动provider,再启动customer |
Closed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
这里的EmptyList对象虽然是可序列化的,但是是一个immutable列表。
所以在Dubbo夸服务传输时,使用fastjson2对Page对象反序列化,会用List.add方法来添加records元素,导致会抛出UnsupportedOperationException异常。
所以这里的records是否可以用一个非immutable列表作为默认值?
对于PageDTO,描述是作为夸服务使用的,但我不了解怎么解决这个问题,请指教。
The text was updated successfully, but these errors were encountered: