[
https://issues.apache.org/jira/browse/ARIES-2195?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18042736#comment-18042736
]
ASF subversion and git services commented on ARIES-2195:
--------------------------------------------------------
Commit 2c4946240f414b3dac044eb6c7acf08b9613e540 in aries-typedevent's branch
refs/heads/fix-jira-2195 from Timothy James Ward
[ https://gitbox.apache.org/repos/asf?p=aries-typedevent.git;h=2c49462 ]
[aries-typedevent] Fix for ARIES-2195 - Avoid OOM in history configuration
This commit adds tests contributed by Guido Grune and fixes the issue where
policies with a defined minimum and large maximum could trigger an OOM. The
simple fix is to limit the maximum storage using the overall maximum number of
events that the history is permitted to store. This may still waste memory if
there are many different policies set with large maximums and a large total
history capacity, but this can be managed by users selecting appropriate
policies and overall capacities.
Signed-off-by: Tim Ward <[email protected]>
> OutOfMemoryError when configure history storage with open range policy
> ----------------------------------------------------------------------
>
> Key: ARIES-2195
> URL: https://issues.apache.org/jira/browse/ARIES-2195
> Project: Aries
> Issue Type: Bug
> Components: Typed Event
> Affects Versions: typedevent-0.0.2
> Environment: Test to reproduce the error:
> {code:java}
> package org.apache.aries.typedevent.bus.impl;
> import java.util.Collections;
> import org.junit.jupiter.api.Test;
> import org.osgi.service.typedevent.monitor.RangePolicy;
> class TypedEventMonitorImplTest {
> @Test
> void testConfigureHistoryStorage() {
> TypedEventMonitorImpl monitor = new
> TypedEventMonitorImpl(Collections.emptyMap());
> monitor.configureHistoryStorage("a/b/c",
> RangePolicy.unlimited());
> monitor.configureHistoryStorage("a/b/c",
> RangePolicy.atLeast(0));
> monitor.configureHistoryStorage("a/b/c",
> RangePolicy.range(0,Integer.MAX_VALUE));
> monitor.configureHistoryStorage("a/b/c",
> RangePolicy.atLeast(10));
> // fails: monitor.configureHistoryStorage("a/b/c",
> RangePolicy.range(1,Integer.MAX_VALUE));
> }
> }
> {code}
>
> Reporter: Guido Grune
> Priority: Major
>
> Configuring the history storage on the TypedEventMonitorImpl with a
> RangePolice that has an minimum > 0 and without maximum (Integer.MAX_VALUE)
> results in an OutOfMemoryError as he tries to create an array with
> Integer.MAX_VALUE size.
> {code:java}
> java.lang.OutOfMemoryError: Requested array size exceeds VM limit
> at java.base/java.util.ArrayDeque.<init>(ArrayDeque.java:194)
> at
> org.apache.aries.typedevent.bus.impl.TopicHistory.<init>(TopicHistory.java:37)
> at
> org.apache.aries.typedevent.bus.impl.TypedEventMonitorImpl.updateRestrictedHistory(TypedEventMonitorImpl.java:373)
> at
> org.apache.aries.typedevent.bus.impl.TypedEventMonitorImpl.configureHistoryStorage(TypedEventMonitorImpl.java:362)
> at
> org.apache.aries.typedevent.bus.impl.TypedEventMonitorImplTest.testConfigureHistoryStorage(TypedEventMonitorImplTest.java:36){code}
> Some discussions about the array with Interger.MAX_VALUE topic:
> [https://stackoverflow.com/questions/3038392/do-java-arrays-have-a-maximum-size]
> [https://stackoverflow.com/questions/31382531/why-i-cant-create-an-array-with-large-size]
--
This message was sent by Atlassian Jira
(v8.20.10#820010)