Friday, February 1, 2013

RPC - Silent failure using LinkedHashMap

In a serialized class (Solutions) sent to the client via RPC, I have this method:
    @SuppressWarnings("unchecked")
    public LinkedHashMap<String, SolutionBase> copyMap() {
        return (LinkedHashMap<String, SolutionBase>) solutionsMap.clone();
    }

In the class containing a Solutions object, I have this method call:
LinkedHashMap<String, SolutionBase> excludedSolutions = model.getSolutions().copyMap();

The above works fine in hosted mode. As soon as I run in web mode, the application fails silently - no js console errors or any notification I can find. The RPC call works; I see the payload sent to the client, but the code after the RPC call is never executed.

I tried removing the clone() and it still fails.

What works is changing the returned type from LinkedHashMap to a HashMap. Note: the underlying solutionsMap is still a LinkedHashMap, just the cast has been changed.

The new declaration:
    @SuppressWarnings("unchecked")
    public HashMap<String, SolutionBase> copyMap() {
        return (HashMap<String, SolutionBase>) solutionsMap.clone();
    }

The new call:
HashMap<String, SolutionBase> excludedSolutions = model.getSolutions().copyMap();

Any thoughts? Should I file as a bug?

Thanks,
Peter

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" 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 http://groups.google.com/group/google-web-toolkit?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments:

Post a Comment