Bug 26614

Summary: XPathUtil.JstlVariableContext.notNull ignores prefix arg value for exception messasge
Product: Taglibs Reporter: Kris Schneider <kschneider>
Component: Standard TaglibAssignee: Tomcat Developers Mailing List <dev>
Status: RESOLVED FIXED    
Severity: normal CC: kschneider
Priority: P3    
Version: 1.1   
Target Milestone: ---   
Hardware: Other   
OS: other   

Description Kris Schneider 2004-02-02 19:52:38 UTC
The current code for XPathUtil.JstlVariableContext.notNull looks like:

        private Object notNull(Object o, String prefix, String localName)
        throws UnresolvableException {
            if (o == null) {
                throw new UnresolvableException("$" +
(prefix==null?"":"prefix"+":") + localName);
            }
            //p("resolved to: " + o);
            return o;
        }

Which means that if the prefix arg is non-null, the exception message will
always include the literal string "prefix" as opposed to the arg's value. The
fix is to do something like:

        private Object notNull(Object o, String prefix, String localName)
        throws UnresolvableException {
            if (o == null) {
                throw new UnresolvableException("$" +
(prefix==null?"":prefix+":") + localName);
            }
            //p("resolved to: " + o);
            return o;
        }

I can't create a diff/patch while at work, but the fix is pretty simple. I'll
try to upload a diff tonight unless somebody else beats me to it...
Comment 1 Felipe Leme 2004-03-10 03:44:50 UTC
Fixed (sorry, beat it while cleaning up other bugs :-)

MAIN BRANCH
------------

diff -r1.16 XPathUtil.java
363c363
<                 throw new UnresolvableException("$" +
(prefix==null?"":"prefix"+":") + localName);
---
>                 throw new UnresolvableException("$" +
(prefix==null?"":prefix+":") + localName);

BRANCH_1.0
-----------
diff -r1.8.2.2 XPathUtil.java
158,159c158,160
<           if (o == null)
<               throw new UnresolvableException("$" + prefix + ":" + localName);---
>             if (o == null) {
>                 throw new UnresolvableException("$" +
(prefix==null?"":prefix+":") + localName);
>             }