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

BUG: DirectSchedulerFactory not set threadpool prefix properly #156

Closed
vision57 opened this issue Jun 27, 2017 · 2 comments
Closed

BUG: DirectSchedulerFactory not set threadpool prefix properly #156

vision57 opened this issue Jun 27, 2017 · 2 comments
Milestone

Comments

@vision57
Copy link

After creating scheduler instance with DirectSchedulerFactory#createVolatileScheduler, I find that thread prefix of scheduler thread pool is not set properly. Here is thread dump:

"null-SimpleThreadPoolWorker-3" prio=10 tid=0x00007fd63438b800 nid=0x69e9 in Object.wait() [0x00007fd623ffe000]
   java.lang.Thread.State: TIMED_WAITING (on object monitor)
        at java.lang.Object.wait(Native Method)
        at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:552)
        - locked <0x0000000791f482a0> (a org.quartz.simpl.SimpleThreadPool$WorkerThread)

"null-SimpleThreadPoolWorker-2" prio=10 tid=0x00007fd63438b000 nid=0x69e8 in Object.wait() [0x00007fd628106000]
   java.lang.Thread.State: TIMED_WAITING (on object monitor)
        at java.lang.Object.wait(Native Method)
        at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:552)
        - locked <0x0000000791f48158> (a org.quartz.simpl.SimpleThreadPool$WorkerThread)

"null-SimpleThreadPoolWorker-1" prio=10 tid=0x00007fd63438e800 nid=0x69e7 in Object.wait() [0x00007fd628207000]
   java.lang.Thread.State: TIMED_WAITING (on object monitor)
        at java.lang.Object.wait(Native Method)
        at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:552)
        - locked <0x0000000791f47b18> (a org.quartz.simpl.SimpleThreadPool$WorkerThread)

You can see prefix is null. Also I write a piece of code to show this bug:

DirectSchedulerFactory.getInstance().createVolatileScheduler(10);
Scheduler scheduler = DirectSchedulerFactory.getInstance().getScheduler();

QuartzScheduler sched = (QuartzScheduler) FieldUtils.readField(scheduler, "sched", true);
QuartzSchedulerResources resources = (QuartzSchedulerResources) FieldUtils.readField(sched, "resources", true);

SimpleThreadPool threadPool = (SimpleThreadPool) resources.getThreadPool();

Assert.assertTrue(threadPool.getThreadNamePrefix().startsWith("null"));

I think there is a mistake in DirectSchedulerFactory:

image

threadpool is initialized(line 468) before prefix of thread pool is set(line 474).

@zemian
Copy link
Contributor

zemian commented Jun 27, 2017

Thanks for reporting @vision57, it looks like a bug to me.

@zemian
Copy link
Contributor

zemian commented Jun 29, 2017

This is now fixed in ad1159c

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants