[ 
https://issues.apache.org/jira/browse/IO-894?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18131943#comment-18131943
 ] 

Gary D. Gregory commented on IO-894:
------------------------------------

Fixed in git master and [snapshot 
builds|https://repository.apache.org/content/repositories/snapshots/commons-io/commons-io/2.23.0-SNAPSHOT/].

> ByteArraySeekableByteChannel builder throws ClassCastException 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
>            Assignee: Gary D. Gregory
>            Priority: Minor
>             Fix For: 2.23.0
>
>
> 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
(v10.3.26#10030026)

Reply via email to