Sunday, June 18, 2017

Re: Annoying Map containing List bug

Oh, developing with netbeans, using legacy devmode (hosted mode) and using Object with GWT RPC... you really like it hard! hehe so your one permutation draft compilation takes about an hour, isn't it? damn GWT! 😜 I thought that RPC will generate serializers for every subtype of Object, but from the Jens comment looks like it just ignores it in this case, but I bet you use Object in more places, your serializers should be huge! .The last years we have been applying changes to make GWT more lightweight and we have been reducing compilation times even the application have been growing constantly, this also improves debugging experience and app size. Using Object there is against any faster/optimized or even type-safe code, hehe so not saying is a bad idea, just saying it worth finding some alternative 😉.

On Saturday, June 17, 2017 at 8:39:48 PM UTC+2, Edson Richter wrote:
I've found a weird behavior of GWT.
I've a code that communicates with server side via RPC.

The request returns a Map<String, Object> wich runs fine. Until last week, when I spent about 3 days to figure that I can't put a List<Enum> in the map. The problem is not from Server side to Client side, but when the client side try to send the Map back to server side, it throws an error "this$static[signature][2] is not a function", without any clue about the problem.

the server side RPC code is similar to:

public Map<String, Object> getContext() {
  Map<String, Object> myMap = new HashMap<String, Object>();
  List<String> someStrings = new ArrayList<String>();
  List<String> otherStrings = new ArrayList<String>();
  List<SITUACAO> situacoes = new ArrayList<SITUACAO>();

  someStrings.add("Some strings to test");
  otherStrings.add("Other strings to test");
  situacoes.add(SITUACAO.NOVA);
  myMap.put("someString", someStrings);
  myMap.put("otherString", otherStrings);
  myMap.put("someConstant", situacoes);
  return myMap; 
}

The client side receives data, and show a dialog with that data. No error. But when I try to send the map back over the wire, I get the error.

Changing the code to:

public Map<String, Object> getContext() {
  Map<String, Object> myMap = new HashMap<String, Object>();
  List<String> someStrings = new ArrayList<String>();
  List<String> otherStrings = new ArrayList<String>();
  List<String> situacoes = new ArrayList<String>();

  someStrings.add("Some strings to test");
  otherStrings.add("Other strings to test");
  situacoes.add(SITUACAO.NOVA.name());
  myMap.put("someString", someStrings);
  myMap.put("otherString", otherStrings);
  myMap.put("someConstant", situacoes);
  return myMap; 
}

...is a workaround!

In time: before someone try to convince me that a Map<String,Object> is a bad idea, it is working really well - I've a system with about 500.000 lines of code, and I'll not change this.

If you need more details to fix this annoying bug, please let me know.

Regards,

Edson Richter

--
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