Add CloseShieldChannel to close-shielded NIO Channels by ppkarwasz · Pull Request #786 · apache/commons-io (original) (raw)
…nels
Adds Channels.closeShield(Channel) to return a JDK proxy that preserves the delegate’s Channel sub-interfaces and shields the underlying channel from close().
Behavior
close()flips shield state; delegate is not closed.isOpen()reflects shield state.- After shield-close, I/O/mutating methods throw
ClosedChannelException; safe queries (e.g.,NetworkChannel.supportedOptions()) still work. - Fluent methods that return
this(e.g.,SeekableByteChannel.position/truncate,NetworkChannel.bind/setOption) return the proxy. - Stable
equals/hashCode/toString - The method is idempotent (no double-wrapping).
Tests
- All methods of
SeekableByteChannel/NetworkChanneland super-interfaces are tested.
garydgregory changed the title
feat: Add Add CloseShieldChannel to close-shielded NIO ChannelsChannels.closeShield for close-shield proxies of NIO channels
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
[ Show hidden characters]({{ revealButtonHref }})