Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/gwt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/wix/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Gwt 无法将新条目插入反序列化的自动bean映射_Gwt_Autobean - Fatal编程技术网

Gwt 无法将新条目插入反序列化的自动bean映射

Gwt 无法将新条目插入反序列化的自动bean映射,gwt,autobean,Gwt,Autobean,当我尝试向反序列化的映射实例插入一个新条目时,我没有得到任何异常,但映射没有被修改。这个入口点代码探测它。我做错什么了 public class Test2 implements EntryPoint { public interface SomeProxy { Map<String, List<Integer>> getStringKeyMap(); void setStringKeyMap(Map<String, List<Integer

当我尝试向反序列化的映射实例插入一个新条目时,我没有得到任何异常,但映射没有被修改。这个入口点代码探测它。我做错什么了

public class Test2 implements EntryPoint {

public interface SomeProxy {
    Map<String, List<Integer>> getStringKeyMap();
    void setStringKeyMap(Map<String, List<Integer>> value);
}

public interface BeanFactory extends AutoBeanFactory {
    BeanFactory INSTANCE = GWT.create(BeanFactory.class);

    AutoBean<SomeProxy> someProxy();
}

@Override
public void onModuleLoad() {
    SomeProxy proxy = BeanFactory.INSTANCE.someProxy().as();

    proxy.setStringKeyMap(new HashMap<String, List<Integer>>());
    proxy.getStringKeyMap().put("k1", new ArrayList<Integer>());
    proxy.getStringKeyMap().put("k2", new ArrayList<Integer>());

    String payload = AutoBeanCodex.encode(AutoBeanUtils.getAutoBean(proxy)).toString();
    proxy = AutoBeanCodex.decode(BeanFactory.INSTANCE, SomeProxy.class, payload).as();

    // insert a new entry into a deserialized map
    proxy.getStringKeyMap().put("k3", new ArrayList<Integer>());

    System.out.println(proxy.getStringKeyMap().keySet()); // the keySet is [k1, k2] :-( ¿where is k3? 
}

}不应使用AutoBeanCodex.encodeAutoBeanUtils.getAutoBeanproxy.toString;获得有效载荷


我稍后会检查代码,我不知道这是否是导致问题的原因。但它确实与我的典型方法不同。

集合类,如java.util.Set和java.util.List,非常棘手,因为它们根据对象实例进行操作。要使集合可序列化,您应该通过常规类型参数(例如,Map,而不仅仅是Map)指定它们预期包含的对象的特定类型。如果使用原始集合或映射,您将得到臃肿的代码,并容易受到拒绝服务攻击


Font:

Thomas Broyer接受了错误报告。