Skip to content

BUG: DirectSchedulerFactory not set threadpool prefix properly #156

@vision57

Description

@vision57

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions