Challenged tests
https://github.com/jakartaee/servlet/blob/master/tck/tck-runtime/src/main/java/servlet/tck/api/jakarta_servlet_http/httpupgradehandler/HttpUpgradeHandlerTests.java
TCK Version
Jakarta Servlet 6+
Description
The spec says:
When an upgrade request is received, the servlet can invoke the HttpServletRequest.upgrade method, which starts the upgrade process. This method instantiates the given HttpUpgradeHandler class. The returned HttpUpgradeHandler instance may be further customized.
After exiting the service method of the servlet, the servlet container completes the processing of all filters and marks the connection to be handled by the HttpUpgradeHandler. It then calls the HttpUpgradeHandler's init method, passing a WebConnection to allow the protocol handler access to the data streams.
This part of the specification is not correctly covered by the given TCK test:
In the TCKHttpUpgradeHandler the field delimiter is default initialized to the value /
|
private String delimiter = "/"; |
in the TestServlet the delimiter is set to the value /
|
handler.setDelimiter("/"); |
So there is literally no way for the value to be any different than / at any time that can be observed from outside.
A much better way would be:
- Let the value keep the default without implicit initialization (resulting in
null being the value at construction time)
- Let TCKReadListener use
Objects.requireNonNull(delimiter) in the constructor to fail if the value failed to be initialized by TestServlet
- Furthermore
TCKReadListener should have a method that returns the used delimiter
TCKHttpUpgradeHandler#getDelimiter should return the delimiter from TCKReadListener and assert it is non null.
That way the TCK would make sure:
- Instances of a
HttpUpgradeHandler can be initialized
init(WebConnection wc) is not called to early or called never
Additional context
I noticed this here while testing the Jetty Implementation that passes the TCK:
Challenged tests
https://github.com/jakartaee/servlet/blob/master/tck/tck-runtime/src/main/java/servlet/tck/api/jakarta_servlet_http/httpupgradehandler/HttpUpgradeHandlerTests.java
TCK Version
Jakarta Servlet 6+
Description
The spec says:
This part of the specification is not correctly covered by the given TCK test:
In the
TCKHttpUpgradeHandlerthe fielddelimiteris default initialized to the value/servlet/tck/tck-runtime/src/main/java/servlet/tck/api/jakarta_servlet_http/httpupgradehandler/TCKHttpUpgradeHandler.java
Line 29 in 4e6a0b4
in the
TestServletthe delimiter is set to the value/servlet/tck/tck-runtime/src/main/java/servlet/tck/api/jakarta_servlet_http/httpupgradehandler/TestServlet.java
Line 42 in 4e6a0b4
So there is literally no way for the value to be any different than
/at any time that can be observed from outside.A much better way would be:
nullbeing the value at construction time)Objects.requireNonNull(delimiter)in the constructor to fail if the value failed to be initialized byTestServletTCKReadListenershould have a method that returns the used delimiterTCKHttpUpgradeHandler#getDelimitershould return the delimiter fromTCKReadListenerand assert it is nonnull.That way the TCK would make sure:
HttpUpgradeHandlercan be initializedinit(WebConnection wc)is not called to early or called neverAdditional context
I noticed this here while testing the Jetty Implementation that passes the TCK: