commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Oliver Heger (JIRA)" <>
Subject [jira] [Commented] (CONFIGURATION-596) Allow event listener Collections to be lazily created in event.EventSource
Date Sat, 24 Jan 2015 17:10:34 GMT


Oliver Heger commented on CONFIGURATION-596:

In version 1.x, {{AbstractConfiguration}} creates one collection object for normal listeners
and one for error listeners. In version 2.0 (currently in alpha state), there is only a single
list managing all registered event listeners.

Do you have concrete numbers that these objects acutally cause a measurable overhead? After
all, they are just empty {{CopyOnWriteArrayList}} objects. We could create them with a low
initial capacity (as most applications are not expected to register many listeners), but this
will only save a few bytes.

Using lazy initialization to overcome this has its own problems: There is a runtime overhead
each time the lists are accessed, null checks would have to be added, and you would need a
means of synchronization to ensure thread-safe access. In addition, some concrete configuration
implementations register a special error listener which just logs occurring exceptions; in
such cases, nothing is gained.

> Allow event listener Collections to be lazily created in event.EventSource
> --------------------------------------------------------------------------
>                 Key: CONFIGURATION-596
>                 URL:
>             Project: Commons Configuration
>          Issue Type: Improvement
>          Components: Events & Notifications
>    Affects Versions: 1.9
>            Reporter: Vladimir Sitnikov
> It turns out every instance of {{AbstractConfiguration}} creates a couple of {{CopyOnWriteAraryLists}}
for {{event.EventSource}}.
> In our usage patterns in most of the cases the lists are not used.
> Can the lists be lazy-initialized? (that is created on the first addListener request)

This message was sent by Atlassian JIRA

View raw message