[JBoss JIRA] (ISPN-7656) DefaultDataContainer.entrySet().stream().toArray(Object[]::new) may fail
by William Burns (JIRA)
[ https://issues.jboss.org/browse/ISPN-7656?page=com.atlassian.jira.plugin.... ]
William Burns commented on ISPN-7656:
-------------------------------------
Hrmm looking at the entrySet method on DefaultDataContainer it uses the AbstractSet spliterator default which only does DISTINCT, doesn't put SIZED. I will have to look at it closer.
> DefaultDataContainer.entrySet().stream().toArray(Object[]::new) may fail
> ------------------------------------------------------------------------
>
> Key: ISPN-7656
> URL: https://issues.jboss.org/browse/ISPN-7656
> Project: Infinispan
> Issue Type: Bug
> Components: Core
> Reporter: Radim Vansa
> Assignee: William Burns
>
> 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:
> {code}
> 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)
> {code}
> Note that this can also happen without expiration upon concurrent modification. We have to adjust the characteristics (remove {{#SIZED}}) of provided spliterators.
--
This message was sent by Atlassian JIRA
(v7.2.3#72005)
7 years, 9 months
[JBoss JIRA] (ISPN-7656) DefaultDataContainer.entrySet().stream().toArray(Object[]::new) may fail
by William Burns (JIRA)
[ https://issues.jboss.org/browse/ISPN-7656?page=com.atlassian.jira.plugin.... ]
William Burns edited comment on ISPN-7656 at 3/22/17 11:35 AM:
---------------------------------------------------------------
Actually the call to size should be sizeIncludingExpired as it is slower anyways (referencing CacheLoaderInterceptor sorry). But I agree any spliterator shouldn't be SIZED.
was (Author: william.burns):
Actually the call to size should be sizeIncludingExpired as it is slower anyways. But we should remove the SIZED as well.
> DefaultDataContainer.entrySet().stream().toArray(Object[]::new) may fail
> ------------------------------------------------------------------------
>
> Key: ISPN-7656
> URL: https://issues.jboss.org/browse/ISPN-7656
> Project: Infinispan
> Issue Type: Bug
> Components: Core
> Reporter: Radim Vansa
> Assignee: William Burns
>
> 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:
> {code}
> 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)
> {code}
> Note that this can also happen without expiration upon concurrent modification. We have to adjust the characteristics (remove {{#SIZED}}) of provided spliterators.
--
This message was sent by Atlassian JIRA
(v7.2.3#72005)
7 years, 9 months
[JBoss JIRA] (ISPN-7656) DefaultDataContainer.entrySet().stream().toArray(Object[]::new) may fail
by William Burns (JIRA)
[ https://issues.jboss.org/browse/ISPN-7656?page=com.atlassian.jira.plugin.... ]
William Burns commented on ISPN-7656:
-------------------------------------
Actually the call to size should be sizeIncludingExpired as it is slower anyways. But we should remove the SIZED as well.
> DefaultDataContainer.entrySet().stream().toArray(Object[]::new) may fail
> ------------------------------------------------------------------------
>
> Key: ISPN-7656
> URL: https://issues.jboss.org/browse/ISPN-7656
> Project: Infinispan
> Issue Type: Bug
> Components: Core
> Reporter: Radim Vansa
> Assignee: William Burns
>
> 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:
> {code}
> 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)
> {code}
> Note that this can also happen without expiration upon concurrent modification. We have to adjust the characteristics (remove {{#SIZED}}) of provided spliterators.
--
This message was sent by Atlassian JIRA
(v7.2.3#72005)
7 years, 9 months
[JBoss JIRA] (ISPN-7656) DefaultDataContainer.entrySet().stream().toArray(Object[]::new) may fail
by William Burns (JIRA)
[ https://issues.jboss.org/browse/ISPN-7656?page=com.atlassian.jira.plugin.... ]
William Burns updated ISPN-7656:
--------------------------------
Status: Open (was: New)
> DefaultDataContainer.entrySet().stream().toArray(Object[]::new) may fail
> ------------------------------------------------------------------------
>
> Key: ISPN-7656
> URL: https://issues.jboss.org/browse/ISPN-7656
> Project: Infinispan
> Issue Type: Bug
> Components: Core
> Reporter: Radim Vansa
> Assignee: William Burns
>
> 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:
> {code}
> 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)
> {code}
> Note that this can also happen without expiration upon concurrent modification. We have to adjust the characteristics (remove {{#SIZED}}) of provided spliterators.
--
This message was sent by Atlassian JIRA
(v7.2.3#72005)
7 years, 9 months