You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@aries.apache.org by "Guido Grune (Jira)" <ji...@apache.org> on 2025/12/19 14:16:00 UTC

[jira] [Resolved] (ARIES-2195) OutOfMemoryError when configure history storage with open range policy

     [ https://issues.apache.org/jira/browse/ARIES-2195?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Guido Grune resolved ARIES-2195.
--------------------------------
    Resolution: Fixed

> 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
>            Assignee: Timothy James Ward
>            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)