Hi everyone!

I was debugging through JenkinsRule from Jenkins Test Harness. After the 
Jetty server and Jenkins have both been terminated in JenkinsRule#after() (line 
488 
<https://github.com/jenkinsci/jenkins-test-harness/blob/2281a68194604c983e7a8d1e7822379b262f153d/src/main/java/org/jvnet/hudson/test/JenkinsRule.java#L488>
 
and line 502 
<https://github.com/jenkinsci/jenkins-test-harness/blob/2281a68194604c983e7a8d1e7822379b262f153d/src/main/java/org/jvnet/hudson/test/JenkinsRule.java#L502>,
 
respectively) stray threads keep running. Attached is the dump of the 
running threads. Is it possible to terminate these threads to allow the JVM 
to exit gracefully?

This issue may already have been reported before in this Stack Overflow 
question: 
https://stackoverflow.com/questions/13769007/jetty-server-leaves-behind-threads-after-stop

A minimal example would be following test code and setting a breakpoint at 
the System.gc() call on line 517:

import org.junit.Rule;
import org.junit.Test;
import org.jvnet.hudson.test.JenkinsRule;

public class RandomTest {
    @Rule
    public JenkinsRule jenkinsRule = new JenkinsRule();

    @Test
    public void randomTest() {
        System.out.println("Hello world");
    }
}


Thanks 
Abhyudaya Sharma

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-dev/69803027-2066-4650-837e-b922f86d7531%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
"qtp593573025-56@5562" prio=5 tid=0x38 nid=NA runnable
  java.lang.Thread.State: RUNNABLE
          at 
sun.nio.ch.WindowsSelectorImpl$SubSelector.poll0(WindowsSelectorImpl.java:-1)
          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 <0x16d8> (a sun.nio.ch.WindowsSelectorImpl)
          - locked <0x16d9> (a java.util.Collections$UnmodifiableSet)
          - locked <0x16da> (a sun.nio.ch.Util$3)
          at sun.nio.ch.SelectorImpl.select(SelectorImpl.java:97)
          at sun.nio.ch.SelectorImpl.select(SelectorImpl.java:101)
          at 
org.eclipse.jetty.io.ManagedSelector$SelectorProducer.select(ManagedSelector.java:234)
          at 
org.eclipse.jetty.io.ManagedSelector$SelectorProducer.produce(ManagedSelector.java:187)
          at 
org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:211)
          at 
org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.produce(EatWhatYouKill.java:126)
          at 
org.eclipse.jetty.io.ManagedSelector$$Lambda$10.1688310330.run(Unknown 
Source:-1)
          at 
org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:672)
          at 
org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:590)
          at java.lang.Thread.run(Thread.java:748)

"qtp593573025-55@5561" prio=5 tid=0x37 nid=NA runnable
  java.lang.Thread.State: RUNNABLE
          at 
sun.nio.ch.WindowsSelectorImpl$SubSelector.poll0(WindowsSelectorImpl.java:-1)
          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 <0x16db> (a sun.nio.ch.WindowsSelectorImpl)
          - locked <0x16dc> (a java.util.Collections$UnmodifiableSet)
          - locked <0x16dd> (a sun.nio.ch.Util$3)
          at sun.nio.ch.SelectorImpl.select(SelectorImpl.java:97)
          at sun.nio.ch.SelectorImpl.select(SelectorImpl.java:101)
          at 
org.eclipse.jetty.io.ManagedSelector$SelectorProducer.select(ManagedSelector.java:234)
          at 
org.eclipse.jetty.io.ManagedSelector$SelectorProducer.produce(ManagedSelector.java:187)
          at 
org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:211)
          at 
org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.produce(EatWhatYouKill.java:126)
          at 
org.eclipse.jetty.io.ManagedSelector$$Lambda$10.1688310330.run(Unknown 
Source:-1)
          at 
org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:672)
          at 
org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:590)
          at java.lang.Thread.run(Thread.java:748)

"qtp593573025-54@5560" prio=5 tid=0x36 nid=NA runnable
  java.lang.Thread.State: RUNNABLE
          at 
sun.nio.ch.WindowsSelectorImpl$SubSelector.poll0(WindowsSelectorImpl.java:-1)
          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 <0x16de> (a sun.nio.ch.WindowsSelectorImpl)
          - locked <0x16df> (a java.util.Collections$UnmodifiableSet)
          - locked <0x16e0> (a sun.nio.ch.Util$3)
          at sun.nio.ch.SelectorImpl.select(SelectorImpl.java:97)
          at sun.nio.ch.SelectorImpl.select(SelectorImpl.java:101)
          at 
org.eclipse.jetty.io.ManagedSelector$SelectorProducer.select(ManagedSelector.java:234)
          at 
org.eclipse.jetty.io.ManagedSelector$SelectorProducer.produce(ManagedSelector.java:187)
          at 
org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:211)
          at 
org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.produce(EatWhatYouKill.java:126)
          at 
org.eclipse.jetty.io.ManagedSelector$$Lambda$10.1688310330.run(Unknown 
Source:-1)
          at 
org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:672)
          at 
org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:590)
          at java.lang.Thread.run(Thread.java:748)

"qtp593573025-53@5559" prio=5 tid=0x35 nid=NA runnable
  java.lang.Thread.State: RUNNABLE
          at 
sun.nio.ch.WindowsSelectorImpl$SubSelector.poll0(WindowsSelectorImpl.java:-1)
          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 <0x16e1> (a sun.nio.ch.WindowsSelectorImpl)
          - locked <0x16e2> (a java.util.Collections$UnmodifiableSet)
          - locked <0x16e3> (a sun.nio.ch.Util$3)
          at sun.nio.ch.SelectorImpl.select(SelectorImpl.java:97)
          at sun.nio.ch.SelectorImpl.select(SelectorImpl.java:101)
          at 
org.eclipse.jetty.io.ManagedSelector$SelectorProducer.select(ManagedSelector.java:234)
          at 
org.eclipse.jetty.io.ManagedSelector$SelectorProducer.produce(ManagedSelector.java:187)
          at 
org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:211)
          at 
org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.produce(EatWhatYouKill.java:126)
          at 
org.eclipse.jetty.io.ManagedSelector$$Lambda$10.1688310330.run(Unknown 
Source:-1)
          at 
org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:672)
          at 
org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:590)
          at java.lang.Thread.run(Thread.java:748)

"Executing 
randomTest(com.michelin.cio.hudson.plugins.rolestrategy.RandomTest)@1" prio=5 
tid=0x1 nid=NA runnable
  java.lang.Thread.State: RUNNABLE
          at org.jvnet.hudson.test.JenkinsRule.after(JenkinsRule.java:517)
          at org.jvnet.hudson.test.JenkinsRule$1.evaluate(JenkinsRule.java:572)
          at org.junit.rules.RunRules.evaluate(RunRules.java:20)
          at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
          at 
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
          at 
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
          at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
          at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
          at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
          at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
          at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
          at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
          at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
          at 
com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
          at 
com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
          at 
com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
          at 
com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)

"Scheduler-543409470@5568" prio=5 tid=0x3d nid=NA waiting
  java.lang.Thread.State: WAITING
          at sun.misc.Unsafe.park(Unsafe.java:-1)
          at 
java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:215)
          at 
java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2078)
          at 
java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1093)
          at 
java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:809)
          at 
java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1074)
          at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1134)
          at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
          at java.lang.Thread.run(Thread.java:748)

"qtp593573025-57-acceptor-0@40ee4467-ServerConnector@4e29b20a{HTTP/1.1,[http/1.1]}{0.0.0.0:50577}@5563"
 prio=3 tid=0x39 nid=NA runnable
  java.lang.Thread.State: RUNNABLE
          at 
sun.nio.ch.ServerSocketChannelImpl.accept0(ServerSocketChannelImpl.java:-1)
          at 
sun.nio.ch.ServerSocketChannelImpl.accept(ServerSocketChannelImpl.java:422)
          at 
sun.nio.ch.ServerSocketChannelImpl.accept(ServerSocketChannelImpl.java:250)
          - locked <0x16d7> (a java.lang.Object)
          at 
org.eclipse.jetty.server.ServerConnector.accept(ServerConnector.java:352)
          at 
org.eclipse.jetty.server.AbstractConnector$Acceptor.run(AbstractConnector.java:603)
          at 
org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:672)
          at 
org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:590)
          at java.lang.Thread.run(Thread.java:748)

"Computer.threadPoolForRemoting [#1]@5522" daemon prio=5 tid=0x34 nid=NA waiting
  java.lang.Thread.State: WAITING
          at sun.misc.Unsafe.park(Unsafe.java:-1)
          at 
java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:215)
          at 
java.util.concurrent.SynchronousQueue$TransferStack.awaitFulfill(SynchronousQueue.java:460)
          at 
java.util.concurrent.SynchronousQueue$TransferStack.transfer(SynchronousQueue.java:362)
          at 
java.util.concurrent.SynchronousQueue.poll(SynchronousQueue.java:941)
          at 
java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1073)
          at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1134)
          at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
          at java.lang.Thread.run(Thread.java:748)

"qtp593573025-60@5566" prio=5 tid=0x3c nid=NA waiting
  java.lang.Thread.State: WAITING
          at sun.misc.Unsafe.park(Unsafe.java:-1)
          at 
java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:215)
          at 
java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2078)
          at 
org.eclipse.jetty.util.BlockingArrayQueue.poll(BlockingArrayQueue.java:392)
          at 
org.eclipse.jetty.util.thread.QueuedThreadPool.idleJobPoll(QueuedThreadPool.java:564)
          at 
org.eclipse.jetty.util.thread.QueuedThreadPool.access$800(QueuedThreadPool.java:49)
          at 
org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:627)
          at java.lang.Thread.run(Thread.java:748)

"qtp593573025-59@5565" prio=5 tid=0x3b nid=NA waiting
  java.lang.Thread.State: WAITING
          at sun.misc.Unsafe.park(Unsafe.java:-1)
          at 
java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:215)
          at 
java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2078)
          at 
org.eclipse.jetty.util.BlockingArrayQueue.poll(BlockingArrayQueue.java:392)
          at 
org.eclipse.jetty.util.thread.QueuedThreadPool.idleJobPoll(QueuedThreadPool.java:564)
          at 
org.eclipse.jetty.util.thread.QueuedThreadPool.access$800(QueuedThreadPool.java:49)
          at 
org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:627)
          at java.lang.Thread.run(Thread.java:748)

"qtp593573025-58@5564" prio=5 tid=0x3a nid=NA waiting
  java.lang.Thread.State: WAITING
          at sun.misc.Unsafe.park(Unsafe.java:-1)
          at 
java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:215)
          at 
java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2078)
          at 
org.eclipse.jetty.util.BlockingArrayQueue.poll(BlockingArrayQueue.java:392)
          at 
org.eclipse.jetty.util.thread.QueuedThreadPool.idleJobPoll(QueuedThreadPool.java:564)
          at 
org.eclipse.jetty.util.thread.QueuedThreadPool.access$800(QueuedThreadPool.java:49)
          at 
org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:627)
          at java.lang.Thread.run(Thread.java:748)

"Finalizer@5845" daemon prio=8 tid=0x3 nid=NA waiting
  java.lang.Thread.State: WAITING
          at java.lang.Object.wait(Object.java:-1)
          at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:144)
          at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:165)
          at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:216)

"Reference Handler@5846" daemon prio=10 tid=0x2 nid=NA waiting
  java.lang.Thread.State: WAITING
          at java.lang.Object.wait(Object.java:-1)
          at java.lang.Object.wait(Object.java:502)
          at java.lang.ref.Reference.tryHandlePending(Reference.java:191)
          at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:153)

"Attach Listener@5843" daemon prio=5 tid=0x5 nid=NA runnable
  java.lang.Thread.State: RUNNABLE

"Signal Dispatcher@5844" daemon prio=9 tid=0x4 nid=NA runnable
  java.lang.Thread.State: RUNNABLE

Reply via email to