Aryan Ganjoo created IO-894:
-------------------------------
Summary: ByteArraySeekableByteChannel builder crashes with mixed
OpenOption types
Key: IO-894
URL: https://issues.apache.org/jira/browse/IO-894
Project: Commons IO
Issue Type: Bug
Reporter: Aryan Ganjoo
On current Commons IO master,
ByteArraySeekableByteChannel.builder().setOpenOptions(StandardOpenOption.READ,
LinkOption.NOFOLLOW_LINKS).get() throws ClassCastException during
Arrays.sort(openOptions). StandardOpenOption and LinkOption are different enum
types; their compareTo methods cannot order each other. A custom non-Comparable
OpenOption has the same problem. The sort can also reorder the builder-owned
options array.
Expected: mixed OpenOption values should not crash the in-memory channel
builder; unrecognized options can be ignored while READ remains read-only and
WRITE/APPEND retain their existing writability behavior.
A minimal local fix replaces sorting/binary search with an identity-based
membership check and adds read-only/read-write mixed-option regression cases. A
Java harness reproduced the ClassCastException before and passed after. On the
patched candidate, ByteArraySeekableByteChannelTest passed 62/62 and the full
Maven test phase passed 6,635 tests with 33 skipped on JDK 17.
AI Assistance used.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)