[jmock] JMock SingleThreadPolicy run on Finaliser thread?
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 <at> 3: (state = RUNNABLE)
- java.lang.Thread.dumpThreads(Native Method)
- java.lang.Thread.getAllStackTraces(Thread.java:1530)
- org.jmock.internal.SingleThreadedPolicy.dumpThreads(SingleThreadedPolicy.java:45)
- org.jmock.internal.SingleThreadedPolicy.reportError(SingleThreadedPolicy.java:40)
- org.jmock.internal.SingleThreadedPolicy.checkRunningOnTestThread(SingleThreadedPolicy.java:32)
- org.jmock.internal.SingleThreadedPolicy.access$000(SingleThreadedPolicy.java:14)
- org.jmock.lib.legacy.ClassImposteriser$4.invoke(ClassImposteriser.java:136)
- foo.bar.Foo$$EnhancerByCGLIB$$73c4c541.finalize(<generated>)
- java.lang.ref.Finalizer.invokeFinalizeMethod(Native Method)
- java.lang.ref.Finalizer.runFinalizer(Finalizer.java:83)
- java.lang.ref.Finalizer.access$100(Finalizer.java:14)
- java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:160)
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,
Toby
RSS Feed