In servlet users email alias, there is a discussion of default methods
for listeners.
The jira issue is SERVLET_SPEC-142: Use Java SE 8 default methods for
listeners.
Here are my investigations:
1. We can add no-op default methods to all of the methods in
javax.servlet:
ServletContextAttributeListener, ServletContextListener,
ServletRequestAttributeListener, ServletRequestListener
javax.servlet.http:
HttpSessionActivationListener, HttpSessionAttributeListener,
HttpSessionBindingListener, HttpSessionListener
2. We will "not" add no-op default method to
javax.servlet.http.HttpSessionIdListener
as there is only "one" method there.
3. We do not add no-op default methods to javax.servlet.WriteListener,
ReadListener
as all those methods are important.
Developers need to take a look whether they need to override them.
In fact, similar interface in JDK 8,
java.nio.channels.CompletionHandler, does not have default methods.
4. For javax.servlet.AsyncListener, we don't want default #onComplete as
we may need to clean up resources there.
Similarly, in #onError and #onTimeout.
Should we leave AsyncListener without default methods for now?
Thanks.
Shing Wai Chan