Skip to content

@Resource is always marked as shareable [SPR-10931] #15559

@spring-projects-issues

Description

@spring-projects-issues

Łukasz Rekucki opened SPR-10931 and commented

The following code in CommonAnnotationBeanPostProcessor.java effectively ignores "shareable" flag on @Resource annotation:

private class ResourceElement extends LookupElement {
    protected boolean shareable = true;

    public ResourceElement(Member member, PropertyDescriptor pd) {
        super(member, pd);
    }
    
    @Override
    protected void initAnnotation(AnnotatedElement ae) {
        // ...
        this.shareable = resource.shareable();
    }
}

The problem is that initAnnotation() is called from super, thus the field default is assigned later.


Affects: 3.1.2, 4.0 M3

Referenced from: commits 7bc3e3b, 0a31892

Metadata

Metadata

Assignees

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