You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by bu...@apache.org on 2002/01/15 17:03:12 UTC

DO NOT REPLY [Bug 5865] New: - WriteTag tests for null format string but PropertyMessageResources always returns String.

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

WriteTag tests for null format string but PropertyMessageResources always returns String.

           Summary: WriteTag tests for null format string but
                    PropertyMessageResources always returns String.
           Product: Struts
           Version: Nightly Build
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Custom Tags
        AssignedTo: struts-dev@jakarta.apache.org
        ReportedBy: dmorris@plumcreek.com


Recent changes in versions 1.16 and 1.15 of WriteTag are causing code that 
worked fine with 1.0 to fail. This bug may be related in some way to: 
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=513

In the WriteTag a format String is retrieved for numeric values using 
PropertyMessageResources.getMessage. WriteTag tests for a null return value. In 
this case the PropertyMessageResources.getMessage will never return a null 
because the returnsNull attribute of PropertyMessageResources defaults to 
false. The default is inherited from the MessageResources Class constructor.

When returnsNull is false, the lookup key is returned as the resource 
surrounded by three question marks. As a workaround I added a test in WriteTag 
to test for null or a string that startsWith("???"). That fixed our immediate 
problem. It seems to me that overloading the return value, which should be 
null, with a message is dangerous. But since this behavior is explicitly 
requested when nullReturn is false, I guess it is OK.

In WriteTag.formatValue I changed:
if( formatStr==null) 

To:
if( formatStr==null || formatStr.startsWith("???")) 

This fixed the problem I was experiencing, it seems that calling the 
constructor with true so that a null is returned might be a better fix.

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>