https://bz.apache.org/bugzilla/show_bug.cgi?id=69920

Mark Thomas <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 OS|                            |All

--- Comment #1 from Mark Thomas <[email protected]> ---
(In reply to outsider404 from comment #0)

> WsRemoteEndpointImplBase throws 7 times exception caused by
> sm.getString("wsRemoteEndpoint.closed*
> 
> 6 times it is IllegalStateException, one IOException
> 
> IMHO correct variant is IOException. Let inspect case by case
> IllegalStateException
> 
> 1. WsRemoteEndpointImplBase.WsOutputStream#flush: java.io.OutputStream#flush
> javadoc declares IOException as problem indicatior. Not illegal state
> exception
> 
> 
> 2. WsRemoteEndpointImplBase.WsOutputStream#write(byte[], int, int):
> 3. WsRemoteEndpointImplBase.WsOutputStream#write(int):
> java.io.OutputStream#write is more precise in javadoc:
> Throws:
> IOException – if an I/O error occurs. In particular, an IOException may be
> thrown if the output stream has been closed.

The argument for changing OutputStream is weaker than that for Writer. "may be"
is language that indicates a behaviour is optional. Neither is there any
language present that prevents another exception being used. Consistency with
Writer does add some weight to the argument for changing OutputStream.

> 4. WsRemoteEndpointImplBase.WsWriter#write:
> 5. WsRemoteEndpointImplBase.WsWriter#flush: java.io.Writer javadoc states:
> While the stream is open, the append(char), append(CharSequence),
> append(CharSequence, int, int), flush(), write(int), write(char[]), and
> write(char[], int, int) methods do nothing. After the stream has been
> closed, these methods all throw IOException.

This is the wrong argument. That comment applies to the nullWriter() method.

The correct argument would be to refer to the Javadoc for Writer.close(). That
supports the changes requested.

The Jakarta WebSocket specification is silent on the expected behaviour in
these cases. That strongly suggests the standard java.io behaviour should be
used.

There is a clear case for changing Writer. The case for OutputStream is less
clear but I think the "may be" language combined with the consistency argument
and that this change is backwards compatible (the methods declare IOException)
is sufficient to justify changing OutputStream as well.

> 6. WsRemoteEndpointImplBase#writeMessagePart: this is private class without
> contract, however raising IllegalStateException breaks contract of
> jakarta.websocket.RemoteEndpoint.Basic#sendText(java.lang.String, boolean) :
> Throws:
> IllegalArgumentException – if fragment is null.

No, it doesn't. The Javadoc for RemoteEndpoint.Basic states that all the
sendXxx() methods may throw an IllegalStateException, although for a different
reason.

The Javadoc for RemoteEndpoint.Basic states an IOException should be thrown "if
there is a problem delivering the message". It is arguable whether the
connection being closed meets that description. There is the consistency (with
Writer and OutputStream) argument as well as the fact the the proposed change
is backwards compatible.

I'm leaning towards switching all of these to IOException although I want to
run the Tomcat test cases and the TCK first.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to