Bug 57824 - fireRequestDestroyEvent does not get called when error page is not found
Summary: fireRequestDestroyEvent does not get called when error page is not found
Status: RESOLVED FIXED
Alias: None
Product: Tomcat 7
Classification: Unclassified
Component: Catalina (show other bugs)
Version: 7.0.59
Hardware: PC Windows NT
: P2 normal (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-04-16 17:14 UTC by Michal Ševčenko
Modified: 2015-04-16 18:59 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michal Ševčenko 2015-04-16 17:14:42 UTC
When upgrading tomcat to 7.0.59 we started experience strange errors in WELD integration layer. It seems that when an error occurres (e.g. 403 reported by HttpServletResponse.sendError(HttpServletResponse.SC_FORBIDDEN)), which does not have error page handler declared in web.xml, the org.apache.catalina.Context.fireRequestDestroyEvent does not get called.

The problem may be related to the following change:

https://github.com/markt-asf/tomcat/commit/5e195b2f06dba1be3f90b0a9d1f67604af905e47

which was a fix of BUG#57252.

The problem may be in StandardHostValve

lines 319:324
        ErrorPage errorPage = context.findErrorPage(statusCode);
        if (errorPage == null) {
            // Look for a default error page
            errorPage = context.findErrorPage(0);
        }
        if (errorPage != null && response.setErrorReported()) {

i.e. if error page is not found the reposnse is not marked as "setErrorReported"

and then lines 214-216

            if (!request.isAsync() && !response.isErrorReportRequired()) {
                context.fireRequestDestroyEvent(request);
            }

i.e. if request is synchronous and the error report is not required (caused by missing error page) the important lifecycle method is not called.

The workaround is to declare universal error handler page

	<error-page>
		<location>...</location>
	</error-page>

which ensures that some error page is always found.

The problem may also be related to BUG#57314 as it has the same symptoms reported in

http://weld.cdi-spec.org/documentation/ see What do WELD-xxx warnings mean?

ie WELD-000225, WELD-000335, WELD-000715 errors that report leaked resources caused by missing lifecycle method call.

According to this bug report we thought that the problem is caused by async requests (which we do not use explicitly), but declaring the error page correctly seems to fix the problem.
Comment 1 Violeta Georgieva 2015-04-16 18:59:52 UTC
Hi,

Fix is provided in Tomcat 7 trunk and will be available for 7.0.62 onwards.

Regards,
Violeta