ScanIterator.scan.stream().toList() causes "java.lang.IllegalStateException: Accept exceeded fixed size of 0" on Java 16+ #3002
Labels
type: bug
A general bug
Milestone
Bug Report
Current Behavior
Attempting to call
toList()
(a new stream operation as of Java 16) on a stream obtained from aScanIterator
throws an IllegalStateException originating from several layers deep within the JDK. Tested on both Java 17 and Java 21.This appears to match the description for a similar issue encountered in Spring, if this helps: spring-projects/spring-data-commons#2519. In their case, it has to do with the size or characteristic passed along on creation of the stream leading to a FixedNodeBuilder expecting 0 elements.
The older
.collect(Collectors.toList())
operation does not encounter this issue.Stack trace
Input Code
Input Code
Reproducible right within
ScanIteratorIntegrationTests.java
if running on Java 16 JRE or above:Expected behavior/code
The
toList()
operation returns a list successfully.Environment
Possible Solution
spring-projects/spring-data-commons#2519 points to the commit where they fixed it, although I can't pretend I understand how much of the full commit is required to solve this here.
Updating
ScanIterator.stream()
to set the size to-1
on the spliterator does fix it locally, but not sure if there are knock-on effects that require more code:Additional context
Java version info:
Java 21:
Java 17:
The text was updated successfully, but these errors were encountered: