[ovirt-devel] Arrays.asList and GWT

Roman Mohr rmohr at redhat.com
Tue Jul 19 14:19:23 UTC 2016


Hi List,

Seems like GWT can't handle Arrays.asList not very well. Sharing this
in case others have similar issues:

I was working on a very strange deserialization bug in combination
with GWT [1]. We had a deserialization problem after loading a VM and
trying to send the VM back to the backend.

The error looked like this:

    2016-06-28 12:17:36,206 ERROR [io.undertow.servlet] (default
task-58) Exception while dispatching incoming RPC call:
        java.lang.NumberFormatException: For input string: "undefined"

It turned out that GWT could serialize an ArrayList backed by an
Integer[] array but it could not deserialize it afterwards.

In my case a list returned by ResultSet#getArray in the DAO layer was
sent to GWT:

    entity.setCpuIds(Arrays.asList((Integer[])
rs.getArray("cpu_core_ids").getArray()));

After copying the content over into a regular ArrayList everything
worked fine again.

    entity.setCpuIds(new ArrayList<Integer>(Arrays.asList((Integer[])
rs.getArray("cpu_core_ids").getArray())))

Here is also the gerrit patch set [2].

So if you see strange GWT RPC errors like the one above look out for
"Arrays.asList" in you code :).

Best Regards,

Roman


[1] https://bugzilla.redhat.com/show_bug.cgi?id=1350861
[2] https://gerrit.ovirt.org/#/c/61038/2



More information about the Devel mailing list