-
Notifications
You must be signed in to change notification settings - Fork 4.4k
bug fix for serializing messages with fields of type map #1418
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
bug fix for serializing messages with fields of type map #1418
Conversation
| if(fieldPair.getKey().isMapField() && fieldPair.getValue() instanceof Collection){ | ||
| JsonObject mapObject = new JsonObject(); | ||
| @SuppressWarnings("unchecked") | ||
| Collection<MapEntry<Object,Object>> entries = | ||
| (Collection<MapEntry<Object, Object>>) fieldPair.getValue(); | ||
| for(MapEntry<Object,Object> entry : entries){ | ||
| String key = context.serialize(entry.getKey()).getAsString(); | ||
| mapObject.add(key, context.serialize(entry.getValue())); | ||
| } | ||
| ret.add(name, mapObject); | ||
| }else{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| if(fieldPair.getKey().isMapField() && fieldPair.getValue() instanceof Collection){ | |
| JsonObject mapObject = new JsonObject(); | |
| @SuppressWarnings("unchecked") | |
| Collection<MapEntry<Object,Object>> entries = | |
| (Collection<MapEntry<Object, Object>>) fieldPair.getValue(); | |
| for(MapEntry<Object,Object> entry : entries){ | |
| String key = context.serialize(entry.getKey()).getAsString(); | |
| mapObject.add(key, context.serialize(entry.getValue())); | |
| } | |
| ret.add(name, mapObject); | |
| }else{ | |
| if (fieldPair.getKey().isMapField() && fieldPair.getValue() instanceof Collection) { | |
| JsonObject mapObject = new JsonObject(); | |
| @SuppressWarnings("unchecked") | |
| Collection<MapEntry<Object, Object>> entries = | |
| (Collection<MapEntry<Object, Object>>) fieldPair.getValue(); | |
| for (MapEntry<Object, Object> entry : entries) { | |
| String key = context.serialize(entry.getKey()).getAsString(); | |
| mapObject.add(key, context.serialize(entry.getValue())); | |
| } | |
| ret.add(name, mapObject); | |
| } else { |
| .create(); | ||
| } | ||
|
|
||
| //TODO |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you have a test which shows that this works as expected?
Note that I am not a Maintainer, and it could happen that even if you change this pull request it might not be merged (in the near future).
This pr addresses #1417
Unit tests still need to be wrapped up
This change is