JUnitTestPlugin automatic test refactoring broken in 929

Just wanted to let people know before bug report are filed.
I will release a new version ASAP. However we are also working on other significant enhancements (Method templates and multi-patterns support) that will delay the release. If you cannot leave w/o it just let me know and I will make a special version for 929.

Jacques

4 comments
Comment actions Permalink

JUnitTestPlugin is one of the plugins I use most. I can hardly wait for
the new version. To keep you busy I have found two other issues;-)

1. JunitTestPlugin prints these messages to the console continuously:
MyApplicationListener.beforeWriteActionStart
MyApplicationListener.writeActionStarted
MyApplicationListener.writeActionFinished

2. JUnitTestPlugin freezes IDEA (I have pasted a thread dump below). I
have two projects which have exactly the same root, source and test
directories. When I open the first one and then open the second one in a
new frame, IDEA freezes. Without the JUnitTestPlugin IDEA opens both
projects without problems.
Note that "Annotate untested method with icon in gutter" must be enabled
for the freeze. If it is not enabled the following exception occurs.

2003-09-18 16:37:53,336 ERROR -
plication.impl.ApplicationImpl - Assertion failed: Access is allowed
from event dispatch thread only.
2003-09-18 16:37:53,336 ERROR -
plication.impl.ApplicationImpl - IntelliJ IDEA (Aurora) Build #929
2003-09-18 16:37:53,336 ERROR -
plication.impl.ApplicationImpl - JDK: 1.4.2
2003-09-18 16:37:53,336 ERROR -
plication.impl.ApplicationImpl - VM: Java HotSpot(TM) Client VM
2003-09-18 16:37:53,336 ERROR -
plication.impl.ApplicationImpl - Vendor: Sun Microsystems Inc.
2003-09-18 16:37:53,336 ERROR -
plication.impl.ApplicationImpl - OS: Windows 2000
2003-09-18 16:37:53,336 ERROR -
plication.impl.ApplicationImpl - Last Action: OpenProject
2003-09-18 16:37:53,336 ERROR -
plication.impl.ApplicationImpl -
java.lang.Throwable
at com.intellij.openapi.diagnostic.Logger.assertTrue(Logger.java:29)
at com.intellij.openapi.application.a.d.assertIsDispatchThread(d.java:187)
at com.intellij.openapi.editor.b.df.getAllHighlighters(df.java:32)
at
org.intellij.plugins.junit.UntestedMethodHighlighter.removeUntestedMethodHighlighters(UntestedMethodHighlighter.java:221)
at
org.intellij.plugins.junit.UntestedMethodHighlighter.unmark(UntestedMethodHighlighter.java:171)
at
org.intellij.plugins.junit.config.JUnitTestConfiguration.updateUntestedMethodHighlighterState(JUnitTestConfiguration.java:100)
at
org.intellij.plugins.junit.config.JUnitTestConfiguration.updateInternalState(JUnitTestConfiguration.java:81)
at org.intellij.plugins.config.Config.configChanged(Config.java:37)
at org.intellij.plugins.config.Config$1.run(Config.java:31)
at com.intellij.ide.j.a.b.c(b.java:39)
at com.intellij.ide.j.a.b.a(b.java:40)
at com.intellij.ide.j.a.a.run(a.java:6)
at com.intellij.openapi.application.a.d.runReadAction(d.java:240)
at com.intellij.ide.j.a.b.b(b.java:12)
at com.intellij.openapi.project.a.s.run(s.java)
at com.intellij.progress.c.a(c.java:4)
at com.intellij.openapi.project.a.r.run(r.java:3)
at java.lang.Thread.run(Unknown Source)

Best regards,
Bas




Full thread dump Java HotSpot(TM) Client VM (1.4.2-b28 mixed mode):

"Smooth progress adapter" prio=7 tid=0x1c4a72a0 nid=0x7f8 waiting on
condition
at java.lang.Thread.sleep(Native Method)
at com.intellij.progress.a.g.run(g.java:75)
at java.lang.Thread.run(Unknown Source)

"StartupActivity" prio=7 tid=0x1c51da30 nid=0x350 in Object.wait()

at java.lang.Object.wait(Native Method)
- waiting on (a java.awt.EventQueue$1AWTInvocationLock) at java.lang.Object.wait(Unknown Source) at java.awt.EventQueue.invokeAndWait(Unknown Source) - locked <0x10231af8> (a java.awt.EventQueue$1AWTInvocationLock) at javax.swing.SwingUtilities.invokeAndWait(Unknown Source) at org.intellij.plugins.util.CommandUtil.runWriteAction(CommandUtil.java :78) at org.intellij.plugins.junit.UntestedMethodHighlighter.markUntestedMeth ods(UntestedMethodHighlighter.java:110) at org.intellij.plugins.junit.UntestedMethodHighlighter.markUntestedMeth odsInEditor(UntestedMethodHighlighter.java:102) at org.intellij.plugins.junit.UntestedMethodHighlighter.mark(UntestedMet hodHighlighter.java:159) at org.intellij.plugins.junit.config.JUnitTestConfiguration.updateUntest edMethodHighlighterState(JUnitTestConfiguration.java:98) at org.intellij.plugins.junit.config.JUnitTestConfiguration.updateIntern alState(JUnitTestConfiguration.java:81) at org.intellij.plugins.config.Config.configChanged(Config.java:37) at org.intellij.plugins.config.Config$1.run(Config.java:31) at com.intellij.ide.j.a.b.c(b.java:39) at com.intellij.ide.j.a.b.a(b.java:40) at com.intellij.ide.j.a.a.run(a.java:6) at com.intellij.openapi.application.a.d.runReadAction(d.java:240) at com.intellij.ide.j.a.b.b(b.java:12) at com.intellij.openapi.project.a.s.run(s.java) at com.intellij.progress.c.a(c.java:4) at com.intellij.openapi.project.a.r.run(r.java:3) at java.lang.Thread.run(Unknown Source) "EditorCaretThread" prio=7 tid=0x1c76ed58 nid=0x7fc waiting on condition [1fa5f0 00..1fa5fd90] at java.lang.Thread.sleep(Native Method) at com.intellij.openapi.editor.b.ds.run(ds.java:5) "AWT-EventQueue-1" prio=7 tid=0x1c4d1cb0 nid=0x278 in Object.wait() [1d6bf000..1 d6bfd90] at java.lang.Object.wait(Native Method) - waiting on <0x10b2dca8> (a com.intellij.util.h.s) at java.lang.Object.wait(Unknown Source) at com.intellij.util.h.s.a(s.java:24) - locked <0x10b2dca8>]]> (a com.intellij.util.h.s)
at com.intellij.openapi.application.a.d.runWriteAction(d.java:154)
at
org.intellij.plugins.util.CommandUtil.runAction(CommandUtil.java:147)

at
org.intellij.plugins.util.CommandUtil.access$200(CommandUtil.java:15)

at org.intellij.plugins.util.CommandUtil$2.run(CommandUtil.java:80)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at com.intellij.ide.s.a(s.java:1)
at com.intellij.ide.s.dispatchEvent(s.java:40)
at
java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)

at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown
Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown
Source)
at java.awt.Dialog$1.run(Unknown Source)
at java.awt.Dialog.show(Unknown Source)
at
com.intellij.openapi.ui.DialogWrapper$MyDialog.show(DialogWrapper.jav
a:34)
at
com.intellij.openapi.ui.DialogWrapper.show(DialogWrapper.java:194)
at com.intellij.progress.a.j.run(j.java:1)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at com.intellij.ide.s.a(s.java:1)
at com.intellij.ide.s.dispatchEvent(s.java:40)
at
java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)

at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown
Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)

"Thread-2" prio=7 tid=0x1c47e4b0 nid=0x820 waiting on condition
[1d67f000..1d67f
d90]
at java.lang.Thread.sleep(Native Method)
at com.intellij.progress.f.run(f.java:2)

"com.jniwrapper.NativeResourceCollector" daemon prio=7 tid=0x1c848ca8
nid=0x598
in Object.wait()
at java.lang.Object.wait(Native Method)
- waiting on (a java.lang.ref.ReferenceQueue$Lock) at java.lang.ref.ReferenceQueue.remove(Unknown Source) - locked <0x10ceb5c0> (a java.lang.ref.ReferenceQueue$Lock) at java.lang.ref.ReferenceQueue.remove(Unknown Source) at com.jniwrapper.NativeResourceCollector$1.run(NativeResourceCollector. java:56) "TimerQueue" daemon prio=5 tid=0x1c6c2e58 nid=0x60c in Object.wait() [1d5ff000.. 1d5ffd90] at java.lang.Object.wait(Native Method) - waiting on <0x10c9ed58> (a javax.swing.TimerQueue) at javax.swing.TimerQueue.run(Unknown Source) - locked <0x10c9ed58>]]> (a javax.swing.TimerQueue)
at java.lang.Thread.run(Unknown Source)

"StoreRefreshStatusThread" prio=2 tid=0x1c87ac48 nid=0x7cc waiting on
condition

at java.lang.Thread.sleep(Native Method)
at com.intellij.openapi.vfs.a.a.bk.run(bk.java:3)

"WatchForChangesThread" prio=7 tid=0x1c87aae0 nid=0x680 runnable
[1d46f000..1d46
fd90]
at
com.intellij.vfs.local.win32.FileWatcher.waitForChangeImpl(Native Met
hod)
at com.intellij.vfs.local.win32.FileWatcher.b(FileWatcher.java:29)
at com.intellij.openapi.vfs.a.a.bl.run(bl.java:21)

"AlarmThread" prio=7 tid=0x1c6c6de8 nid=0x630 in Object.wait()
[1d2ff000..1d2ffd
90]
at java.lang.Object.wait(Native Method)
- waiting on (a java.lang.Object) at java.lang.Object.wait(Unknown Source) at com.intellij.util.Alarm$MyThread.run(Alarm.java:12) - locked <0x10b9b740> (a java.lang.Object) "AlarmThread" prio=7 tid=0x1c6c6c80 nid=0x668 in Object.wait() [1d2bf000..1d2bfd 90] at java.lang.Object.wait(Native Method) - waiting on <0x10b9b7a8> (a java.lang.Object) at java.lang.Object.wait(Unknown Source) at com.intellij.util.Alarm$MyThread.run(Alarm.java:12) - locked <0x10b9b7a8>]]> (a java.lang.Object)

"License checker" prio=5 tid=0x1c6109c0 nid=0x34c runnable

at java.net.PlainDatagramSocketImpl.receive(Native Method)
- locked (a java.net.PlainDatagramSocketImpl) at java.net.DatagramSocket.receive(Unknown Source) - locked <0x10b2ac68> (a java.net.DatagramPacket) - locked <0x10b2ac88> (a java.net.MulticastSocket) at com.intellij.ide.o.g.d(g.java:1) at com.intellij.idea.h.run(h.java:7) at java.lang.Thread.run(Unknown Source) "Java2D Disposer" daemon prio=10 tid=0x1c55be20 nid=0x7a0 in Object.wait() [1ccb f000..1ccbfd90] at java.lang.Object.wait(Native Method) - waiting on <0x10a671d0> (a java.lang.ref.ReferenceQueue$Lock) at java.lang.ref.ReferenceQueue.remove(Unknown Source) - locked <0x10a671d0> (a java.lang.ref.ReferenceQueue$Lock) at java.lang.ref.ReferenceQueue.remove(Unknown Source) at sun.java2d.Disposer.run(Unknown Source) at java.lang.Thread.run(Unknown Source) "AWT-Windows" daemon prio=7 tid=0x1c5824d8 nid=0x67c runnable [1cc2f000..1cc2fd9 0] at sun.awt.windows.WToolkit.eventLoop(Native Method) at sun.awt.windows.WToolkit.run(Unknown Source) at java.lang.Thread.run(Unknown Source) "AWT-Shutdown" prio=5 tid=0x1c58d4a0 nid=0x220 in Object.wait() [1cbef000..1cbef d90] at java.lang.Object.wait(Native Method) - waiting on <0x10a4c208> (a java.lang.Object) at java.lang.Object.wait(Unknown Source) at sun.awt.AWTAutoShutdown.run(Unknown Source) - locked <0x10a4c208>]]> (a java.lang.Object)
at java.lang.Thread.run(Unknown Source)

"Lock thread" prio=5 tid=0x1c5456a0 nid=0x7b4 runnable
at java.net.PlainSocketImpl.socketAccept(Native Method)
at java.net.PlainSocketImpl.accept(Unknown Source)
- locked ]]> (a java.net.PlainSocketImpl)
at java.net.ServerSocket.implAccept(Unknown Source)
at java.net.ServerSocket.accept(Unknown Source)
at com.intellij.idea.p.run(p.java:2)
at java.lang.Thread.run(Unknown Source)

"DestroyJavaVM" prio=5 tid=0x00235c20 nid=0x80c waiting on condition


"Signal Dispatcher" daemon prio=10 tid=0x0091e278 nid=0x738 waiting on
condition


"Finalizer" daemon prio=9 tid=0x0091b458 nid=0x718 in Object.wait()
[1c1af000..1
c1afd90]
at java.lang.Object.wait(Native Method)
- waiting on (a java.lang.ref.ReferenceQueue$Lock) at java.lang.ref.ReferenceQueue.remove(Unknown Source) - locked <0x10a08198> (a java.lang.ref.ReferenceQueue$Lock) at java.lang.ref.ReferenceQueue.remove(Unknown Source) at java.lang.ref.Finalizer$FinalizerThread.run(Unknown Source) "Reference Handler" daemon prio=10 tid=0x00919fd0 nid=0x344 in Object.wait() [1c 16f000..1c16fd90] at java.lang.Object.wait(Native Method) - waiting on <0x10a08200> (a java.lang.ref.Reference$Lock) at java.lang.Object.wait(Unknown Source) at java.lang.ref.Reference$ReferenceHandler.run(Unknown Source) - locked <0x10a08200>]]> (a java.lang.ref.Reference$Lock)

"VM Thread" prio=5 tid=0x00959360 nid=0x670 runnable

"VM Periodic Task Thread" prio=10 tid=0x0023f008 nid=0x4b8 waiting on
condition

"Suspend Checker Thread" prio=10 tid=0x0091d928 nid=0x6c8 runnable

0
Comment actions Permalink

The freeze is a known issue and Maxim was helping me look into it from JetBrains. However I haven't got anything from him in a week.
The message printed out are the debugging info for that problem. I will make sure to remove it as soon as we have the problem fixed.

Thanks for your feedback

Jacques

0
Comment actions Permalink

Sorry Jaques, it was just misunderstanding. I think I should have said
explicitly that the problem is in invokeAndWait. Deadlock scenario is as
following:

1. Startup activity runs in some not swing thread in read action (see
deadlock stacktrace).
2. You're calling invokeAndWait in this thread and locking it until the
runnable is finished.
3. That runnable tries to acquire write action which is not possible due to
read action acquired in other thread (see 1).

Voi la, we have a deadlock.

Generally it is not a good idea to require write actions in threads other
than swing dispatch thread via invokeAndWait hack as it easily comes to
deadlock like one shown above. Use invokeLater if sychronous execution does
not matter. Moreover in this particular case write action is not needed as
far as I can see since working with MarkupModel only requires to be executed
in swing thread (swing multithreading limitation) no matter in write action
or not.

Finally, you should use registerPostStartupActivity() instead of
registerStartupActivity() since latter does not have project completely
initialized yet (PSI stuff for example).


Luck!

--

Best regards,
Maxim Shafirov
JetBrains, Inc / IntelliJ Software
http://www.intellij.com
"Develop with pleasure!"


"Jacques Morel" <jacmorel@yahoo.com> wrote in message
news:2136841.1063899758085.JavaMail.itn@is.intellij.net...

The freeze is a known issue and Maxim was helping me look into it from

JetBrains. However I haven't got anything from him in a week.

The message printed out are the debugging info for that problem. I will

make sure to remove it as soon as we have the problem fixed.
>

Thanks for your feedback

>

Jacques



0
Comment actions Permalink

Thank you so much for the detail answer. It makes complete sense now.

Jacques

0

Please sign in to leave a comment.