Jetty

Allow setAttribute on ServletContext that has not been started.

Details

  • Type: Improvement Improvement
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 6.1.9
  • Fix Version/s: 7.0.0pre0, 6.1.10
  • Component/s: None
  • Labels:
    None
  • Number of attachments :
    0

Description

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.

Activity

There are no comments yet on this issue.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: