Issue Details (XML | Word | Printable)

Key: JETTY-557
Type: Improvement Improvement
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Unassigned
Reporter: Greg Wilkins
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Jetty

Allow setAttribute on ServletContext that has not been started.

Created: 17/Apr/08 01:39 AM   Updated: 19/Apr/08 08:56 AM
Component/s: None
Affects Version/s: 6.1.9
Fix Version/s: 7.0.0pre0, 6.1.10

Time Tracking:
Not Specified


 Description  « Hide
From costin (at springsource):

I've experienced an issue with setting a Servlet Attribute before a Context is started.

I've noticed that the ContextHandler has two attribute maps which are used for retrieving ServletContexts attributes.
However, when a Context is started, its local map is created and setting an attribute before simply returns (suggesting that everything is okay).
However, getting the attribute names or removing an attribute throws a NPE since there is no null check:

setAttribute (line 1401):
if (_contextAttributes==null)
return;

getAttributeNames (line 1384) { Enumeration e = _contextAttributes.getAttributeNames(); }

In my case, I'm trying to set an attribute before the context is started through the ServletContext and currently I can't. I can use the ContextHandler interface but that ties me to Jetty.

Would you consider using as fall back the _attributes field if _contextAttributes is null (context not started)? This way the current behaviour will be preserved meaning that listeners will be called only for attributes registered after the context is started.



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
There are no comments yet on this issue.