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

A @Disposes @Named method doesn't work / is not invoked #23318

Closed
alesj opened this issue Jan 31, 2022 · 0 comments · Fixed by #23333
Closed

A @Disposes @Named method doesn't work / is not invoked #23318

alesj opened this issue Jan 31, 2022 · 0 comments · Fixed by #23333
Assignees
Labels
kind/bug Something isn't working
Milestone

Comments

@alesj
Copy link
Contributor

alesj commented Jan 31, 2022

Describe the bug

With this simple configuration

    @Singleton
    @Named("myInput")
    public Input input() {
        return new Input();
    }

    public void startInput(
        @Observes StartupEvent evt,
        @Named("myInput") Input input
    ) {
        log.info("Started input...");
    }

    public void stopInput(
        @Disposes @Named("myInput") AutoCloseable input
    ) throws Exception {
        log.info("Stopping input...");
        input.close();
    }

The stopInput method is never invoked when the app is stopped.

Expected behavior

The stopInput method should be invoked when the app / test is stopped.

Actual behavior

The stopInput method is NOT invoked when the app / test is stopped.

How to Reproduce?

Run this repo's SimpleTest from IDE

You should see this stacktrace

Jan 31, 2022 5:21:39 PM io.quarkus.test.junit.QuarkusTestExtension$ExtensionState close
ERROR: Failed to shutdown Quarkus
java.lang.RuntimeException: Unable to stop Quarkus test resource com.alesj.qcl.test.SimpleTestResource@3eee3e2b
	at io.quarkus.test.common.TestResourceManager.close(TestResourceManager.java:152)
	at io.quarkus.test.junit.QuarkusTestExtension$4.close(QuarkusTestExtension.java:290)
	at io.quarkus.test.junit.QuarkusTestExtension$ExtensionState.close(QuarkusTestExtension.java:1189)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.jupiter.engine.execution.ExtensionValuesStore.lambda$closeAllStoredCloseableValues$3(ExtensionValuesStore.java:68)
	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
	at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
	at java.base/java.util.stream.SortedOps$RefSortingSink.end(SortedOps.java:395)
	at java.base/java.util.stream.Sink$ChainedReference.end(Sink.java:258)
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:510)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
	at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596)
	at org.junit.jupiter.engine.execution.ExtensionValuesStore.closeAllStoredCloseableValues(ExtensionValuesStore.java:68)
	at org.junit.jupiter.engine.descriptor.AbstractExtensionContext.close(AbstractExtensionContext.java:77)
	at org.junit.jupiter.engine.execution.JupiterEngineExecutionContext.close(JupiterEngineExecutionContext.java:53)
	at org.junit.jupiter.engine.descriptor.JupiterEngineDescriptor.cleanUp(JupiterEngineDescriptor.java:67)
	at org.junit.jupiter.engine.descriptor.JupiterEngineDescriptor.cleanUp(JupiterEngineDescriptor.java:29)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$cleanUp$10(NodeTestTask.java:167)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.cleanUp(NodeTestTask.java:167)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:98)
	at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:35)
	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
	at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:54)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:107)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:88)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:54)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:67)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:52)
	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:114)
	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:86)
	at org.junit.platform.launcher.core.DefaultLauncherSession$DelegatingLauncher.execute(DefaultLauncherSession.java:86)
	at org.junit.platform.launcher.core.SessionPerRequestLauncher.execute(SessionPerRequestLauncher.java:53)
	at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:71)
	at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)
	at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235)
	at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)
Caused by: java.lang.IllegalStateException
	at com.alesj.qcl.test.SimpleTestResource.stop(SimpleTestResource.java:22)
	at io.quarkus.test.common.TestResourceManager.close(TestResourceManager.java:150)

Output of uname -a or ver

No response

Output of java -version

No response

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.6.2.Final

Build tool (ie. output of mvnw --version or gradlew --version)

No response

Additional information

No response

@alesj alesj added the kind/bug Something isn't working label Jan 31, 2022
@mkouba mkouba self-assigned this Jan 31, 2022
@mkouba mkouba added this to the 2.8 - main milestone Feb 1, 2022
mkouba added a commit to mkouba/quarkus that referenced this issue Feb 1, 2022
@gsmet gsmet modified the milestones: 2.8 - main, 2.7.1.Final Feb 3, 2022
gsmet pushed a commit to gsmet/quarkus that referenced this issue Feb 3, 2022
- resolves quarkusio#23318

(cherry picked from commit 26f64ca)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants