I'm trying to use the AutoBean encoding so I can pass and parse types over a websocket connection I have. However, there seem to be some bugs with trying to encode AutoBeans on the server side.
I had a structure like
public interface Foo {
}
public interface Bar {
}
public interface A<T extends Foo> {
T getFoo();
void setFoo(T foo);
}
public interface B extends A<Bar> {
@Override Bar getFoo();
@Override void setFoo(Bar foo);
}
but that ended up getting an exception when the setter is called:
java.lang.NullPointerException
at com.google.web.bindery.autobean.vm.impl.MethodPropertyContext.traverse(MethodPropertyContext.java:102)
at com.google.web.bindery.autobean.vm.impl.MethodPropertyContext.accept(MethodPropertyContext.java:75)
at com.google.web.bindery.autobean.shared.impl.AutoBeanCodexImpl$PropertyCoderCreator.maybeCreateCoder(AutoBeanCodexImpl.java:353)
at com.google.web.bindery.autobean.shared.impl.AutoBeanCodexImpl$PropertyCoderCreator.visitReferenceProperty(AutoBeanCodexImpl.java:341)
at com.google.web.bindery.autobean.vm.impl.ProxyAutoBean.traverseProperties(ProxyAutoBean.java:324)
at com.google.web.bindery.autobean.shared.impl.AbstractAutoBean.traverse(AbstractAutoBean.java:166)
at com.google.web.bindery.autobean.shared.impl.AbstractAutoBean.accept(AbstractAutoBean.java:101)
at com.google.web.bindery.autobean.shared.impl.AutoBeanCodexImpl.doCoderFor(AutoBeanCodexImpl.java:521)
at com.google.web.bindery.autobean.shared.impl.AbstractAutoBean.setProperty(AbstractAutoBean.java:276)
at com.google.web.bindery.autobean.vm.impl.ProxyAutoBean.setProperty(ProxyAutoBean.java:253)
at com.google.web.bindery.autobean.vm.impl.BeanMethod$3.invoke(BeanMethod.java:103)
at com.google.web.bindery.autobean.vm.impl.SimpleBeanHandler.invoke(SimpleBeanHandler.java:43)
So I switched it to:
public interface A {
Foo getFoo();
}
public interface B extends A {
@Override Bar getFoo();
@Override void setFoo(Bar foo);
}
but that gets me:
java.lang.RuntimeException: Could not parse payload
at com.google.web.bindery.autobean.vm.impl.JsonSplittable.create(JsonSplittable.java:73)
at com.google.web.bindery.autobean.shared.impl.StringQuoter.split(StringQuoter.java:73)
at com.google.web.bindery.autobean.shared.AutoBeanCodex.encode(AutoBeanCodex.java:84)
Caused by: org.json.JSONException: Duplicate key "foo"
at org.json.JSONObject.putOnce(JSONObject.java:1076)
at org.json.JSONObject.<init>(JSONObject.java:205)
at org.json.JSONObject.<init>(JSONObject.java:402)
at com.google.web.bindery.autobean.vm.impl.JsonSplittable.create(JsonSplittable.java:47)
... 12 more
I'm going to try it with just the super interfaces and no overriding, but I'm not sure the client is going to reconstruct "foo" with the proper type.
I can maybe understand the first one not working since I know RequestFactory and such are always picky about the use of generics also and I've learned to be careful about that. But the second one seems to just be it not paying attention to the override which seems like a problem that should be fixed. On the server-side, I'm using AutoBeanFactorySource to create the AutoBeanFactory, which I see is supposedly "experimental". I'm then using AutoBeanCodex to do the encoding. Has anyone had success encoding AutoBeans on the server-side?