sjvanrossum commented on PR #39458: URL: https://github.com/apache/beam/pull/39458#issuecomment-5116218821
Ah, of course. We may expect any method to be called on the writer thread and `close`, `writeFooter`, `finishWrite` and `cleanup` on a closer thread. Any sane implementation of `Channel` should return a value from `isOpen` that's consistent across threads since `close` is documented to guarantee the following behavior ([docs](https://docs.oracle.com/javase/8/docs/api/java/nio/channels/Channel.html#close--)): >This method may be invoked at any time. If some other thread has already invoked it, however, then another invocation will block until the first invocation is complete, after which it will return without effect. If you mark `channel` as `volatile` and immediately assign that field to a local variable in `close` and `cleanup`, condition the rest of `close` and `cleanup` logic on `isOpen`, then you're set I think. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
