Skip to content

getBeanDefinitionNames should not leak the frozenBeanDefinitionNames array [SPR-14897] #19463

Closed

Description

@spring-projects-issues

Richard Fearn opened SPR-14897 and commented

getBeanDefinitionNames leaks the getBeanDefinitionNames array to callers. It's possible for the caller to modify the array, which affects Spring's internal list of the names of beans in the context.


Affects: 4.3.4

Attachments:

Issue Links:

Activity

  1. spring-projects-issues commented on Nov 11, 2016

    @spring-projects-issues
    CollaboratorAuthor

    Juergen Hoeller commented

    Good point; we're returning a clone of the array now. To be backported to 4.3.5.

    FWIW, in the 4.x line, we have a more efficient getBeanNamesIterator() accessor on ConfigurableListableBeanFactory which is preferably used by Spring Boot already.

  2. spring-projects-issues commented on Nov 11, 2016

    @spring-projects-issues
    CollaboratorAuthor

    Richard Fearn commented

    FWIW, in the 4.x line, we have a more efficient getBeanNamesIterator() accessor on ConfigurableListableBeanFactory which is preferably used by Spring Boot already.

    Thanks - I see that was added in commit 965bea7, though that didn't go into Spring 4.0, which we are currently using (yes, we really need to upgrade!).

    The reason I'm getting the list of bean names is so that I can sort them alphabetically, and dump out a list of them for diagnostic purposes - so getting an iterator vs. an array doesn't make a huge amount of difference. Thanks for the suggestion though!

  3. added
    type: enhancement
    in: core
    on Jan 11, 2019
  4. added this to the 4.3.5 milestone on Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

in: coretype: enhancement

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions