• ClassCastException in dumpObject with non-String-key'd SortedMaps

    By Jesse Gallagher 1 decade ago

    The dumpObject control causes a ClassCastException (e.g. "java.lang.Integer incompatible with java.lang.String") when attempting to dump the contents of a TreeMap (and presumably other SortedMaps).

    The immediate cause is in the renderer class com.ibm.xsp.extlib.renderkit.html_extended.misc.DumpObjectRenderer, line 443, which attempts to get a property from the map wrapper using a .toString()'d version of the key:


    Object o = it.next();
    String key = o.toString();
    // ...
    Object value = a.getProperty(key);



    This causes an exception with Maps with keys not comparable with String. A quick fix that worked in my limited testing is to change that line to instead use the original, non-converted key "o":


    Object value = a.getProperty(o);

    • And actually...

      By Jesse Gallagher 1 decade ago

      ...for that matter, it fails differently with non-sorted maps: though it doesn't throw an exception with a HashMap, it reports each key's value as null, which makes sense with converted keys.

      • Perhaps use an iterator over the map instead?

        By Devin Olson 1 decade ago
    • Bug logged

      By Paul Hannan 1 decade ago

      Thanks Jesse for reporting this. I've logged 'PHAN9E4CCA' to track this issue which we're investigating.

       

      • Fix coming in next Extlib release

        By B Gleeson 1 decade ago

        The fix for this issue will be in the next OpenNTF release of the XPages Extension Library, which we hope to release very soon.