Bug 56840

Summary: RewriteValve in context.xml throws NullPointerException
Product: Tomcat 8 Reporter: Michael Stürmer <stuermer>
Component: CatalinaAssignee: Tomcat Developers Mailing List <dev>
Severity: normal    
Priority: P2    
Version: 8.0.9   
Target Milestone: ----   
Hardware: PC   
OS: All   

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:


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+.