Open glassfishrobot opened 9 years ago
@glassfishrobot Commented Reported by anthony_ve
@glassfishrobot Commented stuartdouglas said: I don't think this needs to be specified. If CDI is enabled the container can create the Servlet even if it does not have a default constructor via constructor injection.
@glassfishrobot Commented anthony_ve said: Good point about the constructor's signature, I hadn't considered CDI at the time. However, I believe it's needed to specify error conditions and exceptions, analog to what is already specified for initialization (2.3.2.1) and request handling (2.3.3.2). For example, is a container allowed to attempt instantiation again when a previous attempt failed? And if so, what happens if the constructor throws an UnavailableException? Is it treated the same way as during initialization, or is it treated just as any other kind of failure?
Here's a proposed text - adapted from 2.3.2.1 - for instantiation:
After loading the Servlet class, the container instantiates it for use. If instantiation fails, the container throws a ServletException.
A new instance may be instantiated by the container after a failed instantiation. The exception to this rule is when an UnavailableException (thrown by the servlet's constructor) indicates a minimum time of unavailability, and the container must wait for the period to pass before creating a new servlet instance.
@glassfishrobot Commented pbenedict said: Even if the constructor completes normally, the specification leaves undefined the kind of exception thrown if CDI cannot complete injection. Is it a regular ServletException so the container can instantiate again or is it UnavailableException because failed injection is likely a fatal error?
@glassfishrobot Commented markt_asf said: I'd lean towards any instantiation failure being treated as permanent unless it is an UnavailableException with a specific time frame in which case that should be used.
@glassfishrobot Commented This issue was imported from java.net JIRA SERVLET_SPEC-128
Section 2.3.1 of the specification (Servlet 3.1 Final Release for Evaluation) merely says: "After loading the Servlet class, the container instantiates it for use."
I would like this to be clarified by including the constructor requirements & what happens if these requirements aren't met. For example:
After loading the Servlet class, the container instantiates it for use by invoking the no-args constructor (which may be private). If no such constructor is available, a ServletException is thrown.