vert-x3 / vertx-service-proxy

EventBus Proxy generation
Apache License 2.0
67 stars 58 forks source link

Class cast exceptions when json arrays contain maps #25

Closed cescoffier closed 9 years ago

cescoffier commented 9 years ago

This is a weird issue

When running in distributed mode (so with -cluster) and with a service with such a method:

  void getAll(Handler<AsyncResult<List<Data>>> handler);

(Data is a valid data object)

The proxy client cannot retrieve the result because it get a class cast exception. The generated code expects to receive a JsonArray with only JsonObject. This is true in local, but in remote, the JsonArray contains LinkedHashMap. I suspect an issue in the codec.

This commit is a fix for this case in the proxy template. It checks whether the object is an instance of map, and in this case, it creates the JsonObject and then creates the data object instance from the created JsonObject. Otherwise, the data object instance is created from the given JsonObject.

cescoffier commented 9 years ago

@purplefox @pmlopes @vietj ready for review

pmlopes commented 9 years ago

:+1: