Bug 56840 - RewriteValve in context.xml throws NullPointerException
Summary: RewriteValve in context.xml throws NullPointerException
Status: RESOLVED FIXED
Alias: None
Product: Tomcat 8
Classification: Unclassified
Component: Catalina (show other bugs)
Version: 8.0.9
Hardware: PC All
: P2 normal (vote)
Target Milestone: ----
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-08-12 13:12 UTC by Michael Stürmer
Modified: 2014-08-12 13:34 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Stürmer 2014-08-12 13:12:01 UTC
I've added a RewriteValve in my context.xml, and have a simple rewrite.config with one line:

RewriteRule ^/(?:[^/]+/)?(resources/.*)$ /SAPUI5/$1


When requesting a page with the matching URL, a 500 error is returned:

java.lang.NullPointerException
	org.apache.catalina.connector.Request.getContextPath(Request.java:1901)
	org.apache.catalina.valves.rewrite.RewriteValve.invoke(RewriteValve.java:451)
[...]

I think the problem lies around line 447 in RewriteValve.java:
447                    request.getCoyoteRequest().requestURI().setString(null);
448                    CharChunk chunk = request.getCoyoteRequest().requestURI().getCharChunk();
449                    chunk.recycle();
450                    if (context) {
451                        chunk.append(request.getContextPath());
452                    }

setString(null) sets the MessageBytes type to TYPE_NULL, and (context is true in my case) request.getContextPath() tries to access cleared value, which fails.
Comment 1 Remy Maucherat 2014-08-12 13:34:12 UTC
The fix will be included in 8.0.11+.