Java Mailing List Archive

Home » user.jmock »

[jmock-user] [jmock] JMock SingleThreadPolicy run on Finaliser thread?



Author LoginPost Reply

Hi Folks,

I’m running 2.6-SNAPSHOT (from svn) and am getting exceptions from the SingleThreadPolicy class indicating the test thread isn’t the same as the thread making assertions. Fair enough, but when I dump the threads, it seems like the current thread executing check (in SingleThreadPolicy) is the finaliser thread (see below).


the Mockery is not thread-safe: use a Synchroniser to ensure thread safety

Test thread    : Thread[main,5,main]

Current thread : Thread[Finalizer,8,system]


Thread Finalizer@3: (state = RUNNABLE)

- java.lang.Thread.dumpThreads(Native Method)

- java.lang.Thread.getAllStackTraces(

- org.jmock.internal.SingleThreadedPolicy.dumpThreads(

- org.jmock.internal.SingleThreadedPolicy.reportError(

- org.jmock.internal.SingleThreadedPolicy.checkRunningOnTestThread(

- org.jmock.internal.SingleThreadedPolicy.access$000(

- org.jmock.lib.legacy.ClassImposteriser$4.invoke(


- java.lang.ref.Finalizer.invokeFinalizeMethod(Native Method)

- java.lang.ref.Finalizer.runFinalizer(

- java.lang.ref.Finalizer.access$100(

- java.lang.ref.Finalizer$


I have no idea why this is! Any ideas how I’ve managed this? Is it only when imposterisers are involved?

I see it's related to JMOCK-256 but I'm confused why the finaliser thread's involved. I'm running lots of tests from Ant's junit (batch) task.

Thanks for any pointers,


©2008 - Jax Systems, LLC, U.S.A.