2015-02-23 21:01 GMT+03:00 Doug Forrest <dforr...@opentext.com>:
> The issues were introduced by r1645015 in 7.x and r1644992 in 8.x. Both 
> issues are related to ApplicationContext.getContext(String uri).
>
> Issue 1:
>
> getContext("/ROOT") no longer works. In fact, it doesn't appear to be 
> possible to get the ROOT context using this method any more since the literal 
> uri for ROOT would be "" and the first functional line in the method rejects 
> any uri that doesn't start with "/". This is a serious issue that will break 
> many of my customers if they apply a patch containing this code.
>
> Suggested fix:
>
> if (uri.equals("/ROOT")) uri = "";
>
> at line 269.
>
> Issue 2:
>
> getContext now only returns a valid context if its path matches the passed in 
> uri exactly. This is a huge problem for multiple reasons.
>
> This is a major change in functionality that should not have been introduced 
> in a patch release. This code has accepted a uri that contains path 
> information past the context root for many years across many releases. This 
> behavior mirrors the behavior of every major servlet container available. 
> There is a large amount of existing code out in the wild that relies on this 
> behavior. If an intentional decision were made to change this method to 
> require an exact match, it would be prudent to make such a change in a major 
> release to give users and integrators an opportunity to react to the change.
>
> I don't have a suggested fix for this issue, but I would be happy to come up 
> with one if required.
>
> Thank you for your time.
>


If ServletContext.getContext(String) is actually supposed to perform
prefix-mapping, then it explains why getContext("/ROOT") worked for
you.

getContext("/ROOT") worked just because getContext("/foobar") returns
the ROOT context when there is no "foobar" application.  There is
nothing special in the name "/ROOT" here.  Your "issue 1" and "issue
2" are the same.

1. I think this needs an issue in Bugzilla for Tomcat 7.

2. I think this needs a clarification from Servlet EG at least to fix
their Javadoc. [1]

As of now,
a) There is no explicit mention of prefix matching in [1].
It says "uripath - a String specifying the context path of another web
application in the container."

b) It says "The given path must be begin with /", but context path of
the default context is an empty string (per
ServletContext.getContextPath()).

The prefix matching has annoying consequence that it may return a
different web application, not the one that you expect.


[1] 
http://docs.oracle.com/javaee/7/api/javax/servlet/ServletContext.html#getContext%28java.lang.String%29

Best regards,
Konstantin Kolinko

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to