Skip to content

Application with spring.main.web-application-type=NONE doesn't shut down in conjunction with data mongodb reactive starter #15675

@jddipqd

Description

@jddipqd

Non web application (spring.main.web-application-type=NONE) with the dependency to spring-boot-starter-data-mongodb-reactive will not shutdown when close() is called on it's context.
If spring-boot-starter-data-mongodb-reactive dependency is removed application stops regularly.

Spring Boot version is 2.1.1.RELEASE (but it was also occurring in 2.0.x version)

Here's the thread dump after calling close():

Full thread dump Java HotSpot(TM) 64-Bit Server VM (25.191-b12 mixed mode):

"nioEventLoopGroup-2-1" #18 prio=10 os_prio=2 tid=0x0000000021240800 nid=0x92d8 runnable [0x0000000027b9e000]
   java.lang.Thread.State: RUNNABLE
        at sun.nio.ch.WindowsSelectorImpl$SubSelector.poll0(Native Method)
        at sun.nio.ch.WindowsSelectorImpl$SubSelector.poll(WindowsSelectorImpl.java:296)
        at sun.nio.ch.WindowsSelectorImpl$SubSelector.access$400(WindowsSelectorImpl.java:278)
        at sun.nio.ch.WindowsSelectorImpl.doSelect(WindowsSelectorImpl.java:159)
        at sun.nio.ch.SelectorImpl.lockAndDoSelect(SelectorImpl.java:86)
        - locked <0x00000007713b5550> (a io.netty.channel.nio.SelectedSelectionKeySet)
        - locked <0x00000007713a1e98> (a java.util.Collections$UnmodifiableSet)
        - locked <0x00000007713a1d30> (a sun.nio.ch.WindowsSelectorImpl)
        at sun.nio.ch.SelectorImpl.select(SelectorImpl.java:97)
        at io.netty.channel.nio.SelectedSelectionKeySetSelector.select(SelectedSelectionKeySetSelector.java:62)
        at io.netty.channel.nio.NioEventLoop.select(NioEventLoop.java:757)
        at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:412)
        at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:897)
        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
        at java.lang.Thread.run(Thread.java:748)

"Service Thread" #9 daemon
prio=9 os_prio=0 tid=0x000000001dfc0800 nid=0x3f14 runnable [0x0000000000000000]
d:\Workspaces\workspace\console>   java.lang.Thread.State: RUNNABLE

"C1 CompilerThread2" #8 daemon prio=9 os_prio=2 tid=0x000000001c652800 nid=0x8b98 waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"C2 CompilerThread1" #7 daemon prio=9 os_prio=2 tid=0x000000001c64e800 nid=0x8380 waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"C2 CompilerThread0" #6 daemon prio=9 os_prio=2 tid=0x000000001c64b800 nid=0x7718 waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"Attach Listener" #5 daemon prio=5 os_prio=2 tid=0x000000001c64b000 nid=0x6920 runnable [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"Signal Dispatcher" #4 daemon prio=9 os_prio=2 tid=0x000000001c659800 nid=0x1338 waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"Finalizer" #3 daemon prio=8 os_prio=1 tid=0x0000000002fdd800 nid=0x9b94 in Object.wait() [0x000000001d9af000]
   java.lang.Thread.State: WAITING (on object monitor)
        at java.lang.Object.wait(Native Method)
        - waiting on <0x00000006c32da1b8> (a java.lang.ref.ReferenceQueue$Lock)
        at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:144)
        - locked <0x00000006c32da1b8> (a java.lang.ref.ReferenceQueue$Lock)
        at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:165)
        at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:216)

"Reference Handler" #2 daemon prio=10 os_prio=2 tid=0x000000001c63a800 nid=0x5e60 in Object.wait() [0x000000001d8af000]
   java.lang.Thread.State: WAITING (on object monitor)
        at java.lang.Object.wait(Native Method)
        - waiting on <0x00000006c3c0ce18> (a java.lang.ref.Reference$Lock)
        at java.lang.Object.wait(Object.java:502)
        at java.lang.ref.Reference.tryHandlePending(Reference.java:191)
        - locked <0x00000006c3c0ce18> (a java.lang.ref.Reference$Lock)
        at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:153)

"main" #1 prio=5 os_prio=0 tid=0x0000000002ee2800 nid=0x9d50 in Object.wait() [0x000000000170d000]
   java.lang.Thread.State: WAITING (on object monitor)
        at java.lang.Object.wait(Native Method)
        - waiting on <0x00000007723ad288> (a io.netty.util.concurrent.FastThreadLocalThread)
        at java.lang.Thread.join(Thread.java:1252)
        - locked <0x00000007723ad288> (a io.netty.util.concurrent.FastThreadLocalThread)
        at java.lang.Thread.join(Thread.java:1326)
        at org.springframework.boot.maven.RunMojo.join(RunMojo.java:110)
        at org.springframework.boot.maven.RunMojo.runWithMavenJvm(RunMojo.java:96)
        at org.springframework.boot.maven.AbstractRunMojo.run(AbstractRunMojo.java:249)
        at org.springframework.boot.maven.AbstractRunMojo.execute(AbstractRunMojo.java:198)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:154)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:146)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
        at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:56)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:305)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:954)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:192)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)

"VM Thread" os_prio=2 tid=0x000000001c617800 nid=0x8794 runnable

"GC task thread#0 (ParallelGC)" os_prio=0 tid=0x0000000002ef7800 nid=0x87fc runnable

"GC task thread#1 (ParallelGC)" os_prio=0 tid=0x0000000002ef9000 nid=0x90dc runnable

"GC task thread#2 (ParallelGC)" os_prio=0 tid=0x0000000002efa800 nid=0x2704 runnable

"GC task thread#3 (ParallelGC)" os_prio=0 tid=0x0000000002efd000 nid=0xce0 runnable

"VM Periodic Task Thread" os_prio=2 tid=0x000000001c6ae800 nid=0x78c4 waiting on condition

JNI global references: 839

Heap
 PSYoungGen      total 200192K, used 126492K [0x000000076b800000, 0x000000077d880000, 0x00000007c0000000)
  eden space 184832K, 68% used [0x000000076b800000,0x0000000773387210,0x0000000776c80000)
  from space 15360K, 0% used [0x000000077c980000,0x000000077c980000,0x000000077d880000)
  to   space 19968K, 0% used [0x000000077b180000,0x000000077b180000,0x000000077c500000)
 ParOldGen       total 216064K, used 36008K [0x00000006c2800000, 0x00000006cfb00000, 0x000000076b800000)
  object space 216064K, 16% used [0x00000006c2800000,0x00000006c4b2a348,0x00000006cfb00000)
 Metaspace       used 48553K, capacity 50012K, committed 50176K, reserved 1093632K
  class space    used 6317K, capacity 6654K, committed 6656K, reserved 1048576K

Apparently, the nioEventLoopGroup-2-1 thread is preventing application to shut down.

Attached is the sample minimal project for reproducing the issue.
console.zip

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: supersededAn issue that has been superseded by anothertype: bugA general bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions