Hi Ramindu,

I think you are talking about this [1] StreamEvent class.

StackOverflowError can happen when serializing large linked-list type
objects. This [2] answer may shed some light on your problem. In the last
part of the answer, quote

... But serialization is vulnerable to stack overflow for certain kinds of
> structures; for example, a long linked list with no special writeObject()
> methods will be serialized by recursively writing each link. If you've got
> a 100,000 links (nodes), you're going to try to use 100,000 stack frames,
> and quite likely fail with a StackOverflowError.
>
It's possible to define a writeObject() method for such a list class that,
> when the first link (node) is serialized, simply walks the list and
> serializes each link (node) iteratively; this will prevent the default
> recursive mechanism from being used.


So, implementing writeObject() method for the linked-list (which has
StreamEvent nodes) will solve your problem.

[1]
https://github.com/wso2/siddhi/blob/master/modules/siddhi-core/src/main/java/org/wso2/siddhi/core/event/stream/StreamEvent.java
[2] http://stackoverflow.com/a/439016/1577286

Thanks.

On Thu, Jul 30, 2015 at 6:29 PM, Ramindu De Silva <[email protected]> wrote:

> Hi All,
>
> Currently we are using StreamEvents of the following structure in Siddhi
> when processing events within a Window.
>
> StreamEvent{
>    StreamEvent next
>    Object[] beforeWindowData
>    Object[] onAfterWindowData
>    etc.
> }
>
> Each event is linked to the next event by the attribute 'next' so that a
> chain of events is available for doing complex operations on the set of
> events within a window. However, because of this, as the window size grows,
> a very large nested object is created similar to a LinkedList.
>
> This causes StackOverflowErrors when serializing this particular deeply
> nested object. (Serializing of this object is needed for synching state
> between CEP servers, persisting/saving state etc.) This seems to be
> occurring because Java ObjectOutputStream serializes nested objects in a
> recursive manner by using the Java stack.
>
> Is there a way to serialize a deeply nested object, while preserving the
> chain of objects?
>
> Any suggestion resolving this issue will be greatly appreciated.
>
> Best Regards,
>
> --
> *Ramindu De Silva*
> Software Engineer
> WSO2 Inc.: http://wso2.com
> lean.enterprise.middleware
>
> email: [email protected] <[email protected]>
> mob: +94 772339350
> mob: +94 782731766
>
> _______________________________________________
> Dev mailing list
> [email protected]
> http://wso2.org/cgi-bin/mailman/listinfo/dev
>
>


-- 
Sajith Ariyarathna
Software Engineer; WSO2, Inc.;  http://wso2.com/
mobile: +94 77 6602284, +94 71 3951048
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to