Description
Expected Behavior
When you create a new launch project from the micronaut.io/launch, include the aws-lambda project, and run the application via ./gradlew run
command, the application context is ran twice. This is due to the AwsApiProxyTestServer
embedded server class building and running a new application context. The Jetty embedded server class you get if you change the micronaut runtime to jetty rather than lambda_java does not create a new application context but uses the one that already exists so I believe this is a bug.
Actual Behaviour
Multiple application contexts are built and run.
Steps To Reproduce
Download the basic launch project with aws-lambda feature. Below is the config I used.
applicationType: default
defaultPackage: com.example
testFramework: junit
sourceLanguage: kotlin
buildTool: gradle_kotlin
features: [app-name, aws-lambda, aws-lambda-events-serde, aws-lambda-handler-default, gradle, http-client-test, junit, kotlin, kotlin-application, ksp, logback, micronaut-aot, micronaut-build, micronaut-http-validation, properties, readme, serialization-jackson, shade, snapstart, static-resources, x86]
To show the effect, I created a simple Singleton that runs on a schedule which then you can see is created twice.
@Singleton
class HomeService {
companion object {
private val LOG: Logger = LoggerFactory.getLogger(this::class.java)
}
init {
LOG.info("HomeService initialized with UUID: ${UUID.randomUUID()}")
}
@Scheduled(fixedDelay = "5s")
fun test(){
LOG.info("HomeService test method called")
}
}
Environment Information
- Mac OS 14.5 (23F79)
Example Application
No response
Version
micronautVersion=4.7.6