Skip to content

Singleton-scoped @Bean methods behave like prototypes in a Spring DM environment [SPR-5932] #10601

Closed
@spring-projects-issues

Description

@spring-projects-issues

David Fogel opened SPR-5932 and commented

What we are seeing is that when we use @Configuration-annotated configuration classes to define our beans, that our singleton beans are instead treated as prototype beans. This means that we get new instances of our singletons for each time they are referenced (!!!).

I have created sample code which demonstrates this broken behavior.

This code, when run as a regular spring-ified java application, (NOT OSGi), works as expected (only ONE instance of Foo and Bar are created).

BUT, when the identical code is run via Spring DM, THREE different instances of Bar are created!

Note: I used a FileSystemXmlApplicationContext to load this when running as a normal java application, and put the config.xml file inside a /META-INF/spring folder when running in Spring dm.


Affects: 3.0 M3

Reference URL: http://forum.springsource.org/showthread.php?t=74458

Attachments:

Issue Links:

Referenced from: commits 9e0d87c

Metadata

Metadata

Assignees

No one assigned

    Labels

    in: coreIssues in core modules (aop, beans, core, context, expression)type: bugA general bug

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions