cxf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Willem Jiang (JIRA)" <j...@apache.org>
Subject [jira] Updated: (CXF-1947) Incorrect deserialization of null values in Map
Date Tue, 16 Dec 2008 13:08:44 GMT

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

Willem Jiang updated CXF-1947:
------------------------------

    Fix Version/s: 2.1.4
                   2.0.10

Applied the patch into trunk
http://svn.apache.org/viewvc?rev=726724&view=rev
2.1.x branch
http://svn.apache.org/viewvc?rev=726758&view=rev
2.0.x branch
http://svn.apache.org/viewvc?rev=726946&view=rev

> 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.0.10, 2.1.4, 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.


Mime
View raw message