serializer icon indicating copy to clipboard operation
serializer copied to clipboard

IndexOutOfBoundsException when using values().stream() on empty LazyHashMap

Open ZockiRR opened this issue 11 months ago • 1 comments

Environment Details

  • Eclipse Serializer Version: 1.2.0
  • JDK version: 21.0.1
  • OS: Win 10
  • Used frameworks: -

Describe the bug

Exception in thread "main" java.lang.IndexOutOfBoundsException: Index 0 out of bounds for length 0
	at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:100)
	at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:106)
	at java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:302)
	at java.base/java.util.Objects.checkIndex(Objects.java:385)
	at org.eclipse.serializer.collections.lazy.LazyHashMap.calculateIndexPosition(LazyHashMap.java:545)
	at org.eclipse.serializer.collections.lazy.LazyHashMap$SegmentsSpliterator.<init>(LazyHashMap.java:1388)
	at org.eclipse.serializer.collections.lazy.LazyHashMap$ValueSpliterator.<init>(LazyHashMap.java:1654)
	at org.eclipse.serializer.collections.lazy.LazyHashMap$Values.spliterator(LazyHashMap.java:1170)
	at java.base/java.util.Collection.stream(Collection.java:750)
	at org.eclipse.serializer.collections.lazy.LazyCollection.stream(LazyCollection.java:75)

To Reproduce

new LazyHashMap<String, String>().values().stream().toList();

Expected behavior

No Exception, just an empty List as result.

ZockiRR avatar Mar 17 '24 18:03 ZockiRR