Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@Configurable doesn't work with LTW if configurable class has a method returning another configurable class [SPR-12376] #16983

Closed
spring-issuemaster opened this issue Oct 25, 2014 · 3 comments

Comments

@spring-issuemaster
Copy link
Collaborator

@spring-issuemaster spring-issuemaster commented Oct 25, 2014

Christian Rudolph opened SPR-12376 and commented

If a class is annotated @Configurable, load time weaving is enabled and one method returns another configurable class, the referenced class doesn't get weaved (if not weaved until the first class is loaded).

I have attached a small example project (using Web-MVC) which demonstrates the issue.

Foo is the first configurable class, which references another configurable class, Foobar:

@Configurable(autowire = Autowire.BY_TYPE)
public class Foo {
    private Logger log = LoggerFactory.getLogger(Foo.class);
    private Bar bar;

    @Autowired
    public void setBar(Bar bar) {
        log.info("autowiring Bar");
        this.bar = bar;
    }

    public String say() {
        return new Foobar().say() + bar.say();
    }

    //public Set<Foobar> dummy1() { return null; } // fails
    //public Foobar dummy2() { return null; }      // fails
    public void dummy3(Foobar o) {}
    public void dummy4(Foobar o) { new Foobar(); }
}

There are four dummy methods, the first two of them causing Foobar not to get weaved anymore if present. The pure existence of them is enough to cause the failure.

I have configured logging to display weaving information and one log line when autowiring happens in Foo and Foobar.


Affects: 4.1.6

Attachments:

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Oct 26, 2014

Christian Rudolph commented

-Removed dependency to spring-mvc to simplify reproduction of this issue. Just execute gradlew run to run the application.-
The error doesn't occur in the cli version. I deployed the webapp to tomcat 8.0.14, where the error occured.

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Oct 31, 2014

Christian Rudolph commented

If I use TomcatInstrumentableClassLoader with <Loader loaderClass="org.springframework.instrument.classloading.tomcat.TomcatInstrumentableClassLoader"/> in a context.xml file, everything works fine. May I suspect the tomcat classloader to be the root of error?

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Jan 12, 2019

Bulk closing outdated, unresolved issues. Please, reopen if still relevant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.