Coder Social home page Coder Social logo

Comments (6)

wilkinsona avatar wilkinsona commented on June 7, 2024

Thanks for the report.

There's quite a lot going on in the demo application. There are many classes that I don't think are related to the problem. Kotlin is also involved which makes things quite a bit more complicated, particularly when using GraalVM. Can you please reduce the classes involved to the bare minimum required to reproduce the problem and, unless the problem only occurs with Kotlin, please write those classes in Java.

from spring-framework.

cmdjulian avatar cmdjulian commented on June 7, 2024

I minified the example in the repository. Please check again. I now identified the main problem. It is not related to kotlin. The main problem seems to be the @Lazy in the BeanPostProcessor. Without that @Lazy the tests run successfully.

from spring-framework.

cmdjulian avatar cmdjulian commented on June 7, 2024

I also tried refactoring my code to use ObjectProvider<MqttProperties> via class MqttSubscriberCollector(private val config: ObjectProvider<MqttProperties>) : BeanPostProcessor but this seems to not work here, as the following error is reported: Caused by: org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'mqtt-de.smartsquare.starter.mqtt.MqttProperties': Requested bean is currently in creation: Is there an unresolvable circular reference?

Any other way I could ditch the @Lazy as a workaround?

from spring-framework.

wilkinsona avatar wilkinsona commented on June 7, 2024

Thanks very much for minimising the sample.

Using ObjectProvider<MqttProperties> seems to work for me (with your Java-based sample) so I'm not sure what's happening for you when you try it using Kotlin.

The use of @Lazy causes MqttProperties to be proxied. Ideally, Spring Framework's AOT support would generate the necessary reflection metadata for this automatically but that isn't happening. I also tried using a @Bean method with a @Lazy parameter:

@Bean
static MqttSubscriberCollector mqttSubscriverCollectior(@Lazy MqttProperties properties) {
    return new MqttSubscriberCollector(properties);
}

My goal was to make the use of @Lazy more obvious such that it would be automatically detected by Framework but it was not successful.

We'll transfer this to the Framework team so that they can investigate.

from spring-framework.

cmdjulian avatar cmdjulian commented on June 7, 2024

Yeah I got it working with ObjectProvider meanwhile. Was just a stupid mistake to eagerly call the getObject() method inside the bean post processors constructor. You were right, that seems to workaround this. Thanks for investigating 😃

from spring-framework.

snicoll avatar snicoll commented on June 7, 2024

Thanks for the report, I believe this is a duplicate of #30985 and we'll validate this sample when we get to it.

from spring-framework.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.