Issue Details (XML | Word | Printable)

Key: GDS-560
Type: Bug Bug
Status: Open Open
Priority: Major Major
Assignee: Franck Wolff
Reporter: Drew Foglia
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
GraniteDS

Arrays and Collections not properly typed with IMap/BasicMap (de)serialization

Created: 10/Nov/09 02:27 PM   Updated: 19/Feb/10 07:16 PM
Component/s: AMF3 (de)serialization
Affects Version/s: 2.1.0_RC1
Fix Version/s: None

Environment: OS X 10.5.8 and Windows XP, Java 5


 Description  « Hide

With the following Java:

private Map<String, List<String>> testMap = new BasicMap<String, String[]>(new HashMap<String, String[]>(2));
    :
    :
testMap.put("key1", new String[] {"val11", "val12", "val13"});
testMap.put("key2", new String[] {"val21", "val22", "val23"});
    :
    :

public Map<String, String[]> getMap() {
    return testMap;
}

public void setMap(Map<String, String[]> map) {
    testMap = new BasicMap<String, String[]>(map);
}


and the AS:

private function getHashHandler(event:ResultEvent):void {
    var map:IMap = ResultEvent(event).result as IMap;
}

    :
    :
var map:IMap = new BasicMap();
map.put("fromFlex", String["d1", "d2", "d3"]);
sessionService.setMap(map);
    :
    :

Getting the map in Flex (remote call to getMap) seems to work fine. However,
setting the map from Flex (remote call to setMap) doesn't. Specifically,
debugging the Java shows the map with a String key (good), but an Object[] for
the value. The latter is not good. Any attempts to consume the value result in
coercion errors. Same issues appear to be with using the Collection classes specified in the generics.


William Draï added a comment - 30/Nov/09 03:41 PM
Are you using the Tide API or simple RemoteObjects. Also what is your server framework.

Franck Wolff added a comment - 09/Feb/10 02:02 PM
I can see many problem with your code:

1. The signature of your field and getter/setter are different: Map<String, List<String>> vs Map<String, String[]>.
2. BasicMap isn't intended to be used in your Java code, use HashMap instead (BasicMap is a GDS internal/helper class for deserialization only).
3. Your AS3 syntax (String["d1", "d2", "d3"]) isn't possible.

So: try with HashMap<String, List<String>> in your Java code, both for the field and the accessors.