You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "Benson Margulies (JIRA)" <ji...@apache.org> on 2008/12/15 17:11:44 UTC

[jira] Resolved: (CXF-1947) Incorrect deserialization of null values in Map

     [ https://issues.apache.org/jira/browse/CXF-1947?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Benson Margulies resolved CXF-1947.
-----------------------------------

       Resolution: Fixed
    Fix Version/s: 2.2

Fix for 2.2. Could be backported for 2.1.x.

> Incorrect deserialization of null values in Map
> -----------------------------------------------
>
>                 Key: CXF-1947
>                 URL: https://issues.apache.org/jira/browse/CXF-1947
>             Project: CXF
>          Issue Type: Bug
>          Components: Aegis Databinding
>    Affects Versions: 2.0, 2.0.1, 2.0.2, 2.0.3, 2.0.4, 2.0.5, 2.1, 2.0.6, 2.1.1, 2.0.7, 2.0.8, 2.1.2, 2.0.9, 2.1.3
>            Reporter: Julien Coloos
>            Assignee: Benson Margulies
>             Fix For: 2.2
>
>
> Hi,
> There is an issue with AEGIS deserialization (at least on server-side) of Maps that contain null values: the retrieved value may not be null, and can actually be the previous value deserialized from the Map.
> For exemple, if the Map contains 3 (key;value) pairs ("0", null), ("1", Object1) and ("2", null), AEGIS will hand over ("0", null), ("1", Object1) and ("2", Object1) to the implementation class.
> I had a quick look at the source code, and I think the issue is in the org.apache.cxf.aegis.type.collection.MapType.readObject(MessageReader, Context) function: the variables holding the key and value objects are declared outside the loop processing the Map elements (named 'entry' in the XML stream), and are not reseted to null for each 'entry' processed.
> So if the 'key' or 'value' tag is absent (meaning the data is null), the code still points to the deserialized data from the previous entry.
> This could be fixed by either moving the declaration of those 2 variables inside the loop, or reseting their values to null at the beginning of the loop.
> Snippet from the function :
>             Object key = null;
>             Object value = null;
>             while (reader.hasMoreElementReaders()) {
>                 MessageReader entryReader = reader.getNextElementReader();
>                 if (entryReader.getName().equals(getEntryName())) {
>                     while (entryReader.hasMoreElementReaders()) {
>                         MessageReader evReader = entryReader.getNextElementReader();
>                         if (evReader.getName().equals(getKeyName())) {
>                             key = kType.readObject(evReader, context);
>                         } else if (evReader.getName().equals(getValueName())) {
>                             value = vType.readObject(evReader, context);
>                         } else {
>                             readToEnd(evReader);
>                         }
>                     }
>                     map.put(key, value);
>                 } else {
>                     readToEnd(entryReader);
>                 }
>             }
> Note: this issue was already present in XFire

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.