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=25391>.
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=25391

AbstractTextSerializer use of Configuration.getLocation() incompatible with 
AvalonFramework 4.1.5

           Summary: AbstractTextSerializer use of
                    Configuration.getLocation() incompatible with
                    AvalonFramework 4.1.5
           Product: Cocoon 2
           Version: Current CVS 2.1
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: sitemap components
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


The AbstractTextSerializer class uses the getLocation() method of the 
Configuration interface to detect whether a child by a given name exists:

    Configuration child = config.getChild( "child" );
    if ( !child.getLocation().equals("-") ) {
        // OK, child exists
    }

However, two things make this bad:

 1. In Avalon Framework 4.1.5 (not 4.1.4 which is being used now), when you do 
a getChild() and the child doesn't exist, the location string will be set to 
the location string of the parent. Thus, no matter whether the child exists or 
not, getLocation will not return "-".

 2. There's a better way of doing it:

    Configuration child = config.getChild( "child", false );
    if ( child != null ) {
        // OK, child exists
    }

Passing false as the second parameter to getChild means "don't create a child 
if one does not exists, return null instead". The above is guaranteed to work, 
and will enable users of 2.1 to upgrade to AF 4.1.5 if and when needed for non-
Cocoon related issues.

Reply via email to