History | Log In     View a printable version of the current page. Get help!  
Issue Details (XML | Word)

Key: STS-333
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Minor Minor
Assignee: Tim Fennell
Reporter: Niklas Therning
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Stripes

Insufficent cleanup in InputTagSupport.doEndTag() on exceptions from TagErrorRenderer

Created: 12/Feb/07 08:35 AM   Updated: 28/Oct/07 08:12 AM
Component/s: Tag Library
Affects Version/s: Release 1.4.2
Fix Version/s: Release 1.4.3


 Description  « Hide
If a custom TagErrorRenderer is used InputTagSupport.doEndTag() won't reset its state properly when the TagErrorRenderer's doAfterEndTag() method throws an exception. If the servlet container pools tags (like Tomcat) this could cause unexpected behaviour.

I think the following code in InputTagSupport:

    public final int doEndTag() throws JspException {
        int result = doEndInputTag();

        if (getFieldErrors() != null) {
            this.errorRenderer.doAfterEndTag();
        }

        if (this.focus) {
            makeFocused();
        }

        this.errorRenderer = null;
        this.fieldErrors = null;
        this.fieldErrorsLoaded = false;
        this.focus = false;

        return result;
    }

 should be changed into something like

    public final int doEndTag() throws JspException {
        try {
            int result = doEndInputTag();

            if (getFieldErrors() != null) {
                this.errorRenderer.doAfterEndTag();
            }

            if (this.focus) {
                makeFocused();
            }

        } finally {
            this.errorRenderer = null;
            this.fieldErrors = null;
            this.fieldErrorsLoaded = false;
            this.focus = false;
        }

        return result;
    }


 All   Comments   Change History      Sort Order:
Tim Fennell [12/Feb/07 09:03 AM]
If a tag throws an exception from any of it's interface methods the container is not allowed to pool the tag for further use. Therefore the above described change would appear to be unnecessary. Are you seeing problems with this in Tomcat, or is this just from browsing the Stripes code?

Niklas Therning [12/Feb/07 09:20 AM]
I've had problems with this in Tomcat. I had some validation errors on my page so my TagErrorRenderer was invoked which threw an exception. After that, whenever I browsed to that same page I would get the same exception even though no form had been posted and no validation should occur.

Tim Fennell [27/Mar/07 04:49 AM]
Resolved in a manner similar to the one described, except that I moved things around enough to get everything but the state cleanup code into the try{} block.