Uploaded image for project: 'Infinispan'
  1. Infinispan
  2. ISPN-7656

DefaultDataContainer.entrySet().stream().toArray(Object[]::new) may fail

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Done
    • Affects Version/s: None
    • Fix Version/s: 9.0.0.Final
    • Component/s: Core
    • Labels:
      None

      Description

      When the default Spliterator estimates size of the array, it calls DefaultDataContainer.EntrySet#size() that returns directly the size of container (including expired entries). Then the container is iterated using ImmutableEntryIterator which excludes expired entries by default, and this may return less elements than the original size() provided. That causes failure like this:

      java.lang.IllegalStateException: End size 1 is less than fixed size 2
      	at java.util.stream.Nodes$FixedNodeBuilder.end(Nodes.java:1232)
      	at java.util.stream.Sink$ChainedReference.end(Sink.java:258)
      	at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482)
      	at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
      	at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:545)
      	at java.util.stream.AbstractPipeline.evaluateToArrayNode(AbstractPipeline.java:260)
      	at java.util.stream.ReferencePipeline.toArray(ReferencePipeline.java:438)
      

      Note that this can also happen without expiration upon concurrent modification. We have to adjust the characteristics (remove #SIZED) of provided spliterators.

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                william.burns Will Burns
                Reporter:
                rvansa Radim Vansa
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: