Skip to content

Unnecessary sort in AbstractApplicationEventMulticaster [SPR-17307] #21840

Closed
@spring-projects-issues

Description

@spring-projects-issues

Nick Hristov opened SPR-17307 and commented

org.springframework.context.event.AbstractApplicationEventMulticaster.ListenerRetriever#getApplicationListeners method performs an unnecessary sort:

It creates a list which is a combination of this.applicationListeners and this.applicationListenerBeans and sorts that list. However, the sorting is unnecessary if either one of the two collections is empty. Furthermore, due to the fact that the sorting utilizes the reflection lookups, this sort can become an expensive unnecessary overhead in some use cases.

In my case, I load large amounts of data (> 1K of objects) via Spring Data Mongo which fires off events for every object loaded in the system.

So the sort operation ends up taking about 38% of the overall cost of the processing, more than any other component in my use case.
 


Affects: 5.0.5

Attachments:

Issue Links:

Backported to: 5.0.10

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)status: backportedAn issue that has been backported to maintenance branchestype: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions