[ https://issues.apache.org/jira/browse/THRIFT-5022?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16978708#comment-16978708 ]
Qinghui Xu commented on THRIFT-5022: ------------------------------------ When I fixed THRIFT-2530, I did not notice such use cases of oneway transport. And indeed my patch would not work in such use cases.-- For the fix I would suggest to use a `closed` flag which should be set to true as soon as `close` is called. This is better because when `inputstream_.close` or `outputstream_.close` is called, there could be some unexpected runtime error (only IOException is caught and treated), and this leads to the `close` method to return prematurely (before being able to set `inputstream_` or `outputstream_` to `null`) > TIOStreamTransport.isOpen is false for InputStream or Outpstream only use. > -------------------------------------------------------------------------- > > Key: THRIFT-5022 > URL: https://issues.apache.org/jira/browse/THRIFT-5022 > Project: Thrift > Issue Type: Task > Components: Java - Library > Affects Versions: 0.13.0 > Reporter: Andy Seaborne > Priority: Major > > This follows from THRIFT-2530. > {{TIOStreamTransaport.isOpen}} changed to be > > {noformat} > public boolean isOpen() { > return inputStream_ != null && outputStream_ != null; > } > {noformat} > but constructors {{TIOStreamTransaport(InputStream)}} and > {{TIOStreamTransaport(OutputStream)}} leave one of {{inputStream_}} or > {{outputStream_}} null. > This makes isOpen false immediately, no close() called. open() does not > change the state of object. > Example: > {noformat} > TIOStreamTransport x1 = new TIOStreamTransport(new ByteArrayInputStream(new > byte[1])); > System.out.println(x1.isOpen()); > TIOStreamTransport x2 = new TIOStreamTransport(new ByteArrayOutputStream()); > System.out.println(x2.isOpen()); > {noformat} > is prints false both times. > > It should be: > {noformat} > public boolean isOpen() { > return inputStream_ != null || outputStream_ != null; > } > {noformat} > or an explicit flag for the open/close state but {{inputStream_ != null || > outputStream_ != null;}} is enough given the current close implementation. > > -- This message was sent by Atlassian Jira (v8.3.4#803005)