On Tuesday, July 18, 2017 at 6:15:23 PM UTC+2, Óscar Frías Barranco wrote:
Hi.
When we modify the code of our GWT application, in particular the classes that travel through GWT calls, these exceptions are generated for many users for a few hours:
com.google.gwt.user.client.rpc.SerializationException: Type '.....' was not assignable to 'com.google.gwt.user.client. rpc.IsSerializable' and did not have a custom field serializer.For security purposes, this type will not be serialized.: instance = .....
We think that this is due to browsers caching the previous (old) code which is no longer aligned with the server code. We have reviewed all HTTP headers related to caching and all of the are, we think, correctly configured.
So our plan is to force a reload of the browser page with a location.reload(true) when we detect that the SerializationException is being thrown at the server.
From a UX point of view, it's probably better to show an error (possibly with a button to reload the app) than forcibly reload, as that could possibly lead to losing data the user has entered.
This is what Google Groups is doing, and it allows users to copy their message before reloading, pasting and re-sending it.
Any ideas about how to implement this easily? Our code if full of AsyncCallback calls and we would like to avoid editing each one of them. Is there a place where we could insert a client code that would be executed for every RPC call and that will call location.reload(true) if a SerializationException is thrown ?
If your GWT.create() for the services are relatively centralized, you could implement wrappers that wrap the AsyncCallback before delegating to the real service.
I.e. from
FooServiceAsync fooService = GWT.create(FooService.class);
to
FooServiceAsync fooService = new FooServiceAsyncWrapper();
with
class FooServiceAsyncWrapper implements FooServiceAsync {
private final FooServiceAsync delegate = GWT.create(FooService.class);
@Override
public void doFoo(int param1, String param2, AsyncCallback<Bar> callback) {
delegate.doFoo(param1, param2, new AsyncCallbackWrapper<Bar>(callback));
}
}
class AsyncCallbackWrapper<T> implements AsyncCallback<T> {
private final AsyncCallback<T> delegate;
public AsyncCallbackWrapper(AsyncCallback<T> delegate) {
this.delegate = delegate;
}
@Override
public void onSuccess(T result) {
delegate.onSuccess(result);
}
@Override
public void onFailure(Throwable caught) {
if (caught instanceof Xxx) {
// handle failure
} else {
delegate.onFailure(caught);
}
}
}
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment