DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=18397>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=18397

order of set-properties-rule execution in Digester 1.4 (1.3 as well)

           Summary: order of set-properties-rule execution in Digester 1.4
                    (1.3 as well)
           Product: Commons
           Version: 1.4 Final
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: Major
          Priority: Other
         Component: Digester
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]
                CC: [EMAIL PROTECTED]


The order of the execution of the setters which apply to a given pattern is 
not reliable. 

How to reproduce:
- digest any XML file with default <set-properties-rule/> (no spec on props to 
set)
- set logger to log the order of the values being set. All looks good.
- put logging statements in the actual setters i nthe destination bean itself.
- Notice that the order in which the setters are called is arbitrary.

This is not always a problem, but if the destination bean relies on the order 
of the attibutes being set (eg. propepulate keys in a destination Map etc., 
then all hell breaks loose - null-pointer exceptions, mismatched Maps of 
attribute-pairs, etc.

How to fix it:
The reason for the bug is that  a HashMap is used in method

    public void begin(Attributes attributes) throws Exception {
        
        // Build a set of attribute names and corresponding values
        HashMap values = new HashMap();
<snip>

If this is replaced with:

    public void begin(Attributes attributes) throws Exception {
        
        // Build a set of attribute names and corresponding values
        Map values = new SequencedHashMap();
<snip>

(notes
1 - HashMap declaration is replaced with Map (better practice anyway)
2 - HashMap constructor is replaced with SequencedHashMap (another great 
apache product).

then all those problems disappear.

First time apache poster, so pls overlook errors in the way I have posted this.

If it is necessary for me to submit this minor fix to CVS pls advise.

Paul Anderson

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to