On 09/06/2012 01:04, Rajiv Mordani wrote:
> On 6/8/12 10:16 AM, Mark Thomas wrote:
>> On 08/06/2012 00:59, Rajiv Mordani wrote:
>>> Like Bill pointed out in the thread - there are some exceptions to the
>>> rule. This is one of the exceptions where metadata-complete does not
>>> disable scanning of ServletContainerInitializers and related annotations
>>> (HandlesTypes) bundled with the application. This was one of the key
>>> pluggability contracts that was added in Servlet 3.0.
>>
>> So I take it then that your view is that it is acceptable for a web
>> application written to the 2.5 API that runs one way on a 2.5 container
>> to run differently on a 3.0+ container due to 3rd party libraries using
>> 3.0+ annotations?
>
> If it was written to a 2.5 API - the library probably never used the
> servlet 3.0 annotations either. So when the application moves to a 3.0
> container - at a minimum the library will have to be updated if they
> want to use that. So the argument that the behavior is going to be
> different does not really make sense.
There are frameworks (I am thinking of Spring) available that will run
on a 2.5 container but can also use 3.0 features if running on a 3.0
container. Spring does this in a way that won't trigger any problems but
it doesn't mean that all frameworks will work that way. It is perfectly
possible to write something that runs one way on a 2.5 container and
differently on a 3.0 container. How likely that is is a different
question but because the possibility exists I think we need to draw some
attention to it.
>> I do not find this at all acceptable. It breaks the principle of least
>> surprise. However, I suspect based on what has already been said that I
>> am not going to win this argument. On that basis I believe we need to do
>> the following:
>>
>> 1. Correct the text of section 1.6.2 of the Servlet 3.0 specification to
>> make clear that some annotations (define which ones) will always be
>> scanned for regardless of the setting of meta-data complete.
>
> We can do that - the only annotation is HandlesTypes AFAIK.
Great. HandlesTypes is the only one I am aware of.
>> 2. Add a clear warning to this section that applications written to
>> previous specification versions may behave differently on new containers
>> due to the presence of annotations (e.g. in third party libraries).
>
> Again - going forward that *may* be true but the argument from 2.5 to
> 3.0 does not hold true.
Unfortunately it does. See above.
> Am not sure that it warrants a warning that
> applications may behave differently however if we have the text that
> says that says some annotations are scanned I think that is good enough.
> We will work on the text needed to clarify the issue.
I think adding something along the lines of the following to 1.6.2 would
be sufficient:
"The annotation scanning in a Servlet 3.0+ container may result in the
enabling of additional features that would not be enabled if running the
same application in a 2.5 or earlier container. For example, a servlet
with a @WebServlet annotation would require explicit mapping in a 2.5
container but would be automatically mapped via the annotation in a
servlet 3.0 container".
There is probably a better (i.e. shorter) way of wording it but the
above is the sense that I think needs to be conveyed.
Mark