Bug 64495 - Rewrite rule threadlocal issue
Summary: Rewrite rule threadlocal issue
Status: RESOLVED DUPLICATE of bug 64432
Alias: None
Product: Tomcat 9
Classification: Unclassified
Component: Catalina (show other bugs)
Version: 9.0.35
Hardware: PC Mac OS X 10.1
: P2 normal (vote)
Target Milestone: -----
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-06-04 04:37 UTC by Melvin A
Modified: 2020-06-04 04:53 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Melvin A 2020-06-04 04:37:38 UTC
Hi,

I am using Rewrite Valve in my server with rewrite.config in the right location. It was working fine. I recently upgraded from 9.0.34 to 9.0.35. I found an issue with Rewrite rule matching.

Digging into the code I found the following,

https://github.com/apache/tomcat/commit/c4b71e31f3183ce3f4b8e86bd2cef49393a2a7e5#diff-2dc33ffdb9d224258577902518d5bfdc

In this particular commit the pattern variable for RewriteRule is made as static. Because of this the first rule declared in rewrite.config is assigned to this variable and all other RewriteRule's pattern are ignored.

Steps to reproduce:

In rewrite config declare two rules say,

RewriteRule ^/url1/(.*)$ /rewrittenurl1/$1 [L]
RewriteRule ^/url2/(.*)$ /rewrittenurl2/$1 [L,QSA]

Now give a request matching second rule i.e <domain>/url2/some/path. It will try to math the url with pattern ^/url1/(.*)$ as the pattern variable is static and is assigned with first RewriteRule parsed.

Additional request:
I am just curious to know why pattern is declared as a ThreadLocal instead of a private variable. 

Regards,

Melvin
Comment 1 Felix Schumacher 2020-06-04 04:53:48 UTC

*** This bug has been marked as a duplicate of bug 64432 ***