Mailing list - Entries of 2006


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[qftestJUI] A possible race condition


  • Subject: [qftestJUI] A possible race condition
  • From: "Kosmylev, Leonid" <Leonid.Kosmylev@?.com>
  • Date: Fri, 17 Mar 2006 11:37:54 +0100

Hi,

We are using qftestJUI version 1.06.0 (build 919) to test our product,
mostly on linux ("uname -r" reports 2.6.11-1.1369_FC4smp).

Recently we started to run into a very strange problem which was tracked to
qftestJUI itself. 

We have piece of code that looks like this:

Runnable  r = ...;
SwingUtilities.invokeLater(r);

Where the runnable is doing quite a lot, including but not limiting to swing
calls. Sometimes (approx. 15%-20% of our test runs) the code in the runnable
is invoked twice. 

We put some debugging output (Thread.dumpStack()) in the runnable's run()
method.

Results:
Test runs where the runnable is invoked once have the following output:

        at <Our runnable's run() method> 
        at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:178)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:454)
        at sun.reflect.GeneratedMethodAccessor38.invoke(Unknown Source)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
.java:25)
        at java.lang.reflect.Method.invoke(Method.java:324)
        at de.qfs.lib.util.Reflector.call(Reflector.java:112)
        at
de.qfs.apps.qftest.client.TestEventQueue.doDispatch(TestEventQueue.java:223)
        at de.qfs.lib.gui.EventQueue.dispatchEvent(EventQueue.java:569)
        at
java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.ja
va:201)
        at
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java
:151)
        at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
        at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)


Test runs where the runnable is invoked twice have the following output:
1. First invocation (note that is it the same as the one above):

        at <Our runnable's run() method> 
        at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:178)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:454)
        at sun.reflect.GeneratedMethodAccessor34.invoke(Unknown Source)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
.java:25)
        at java.lang.reflect.Method.invoke(Method.java:324)
        at de.qfs.lib.util.Reflector.call(Reflector.java:112)
        at
de.qfs.apps.qftest.client.TestEventQueue.doDispatch(TestEventQueue.java:223)
        at de.qfs.lib.gui.EventQueue.dispatchEvent(EventQueue.java:569)
        at
java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.ja
va:201)
        at
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java
:151)
        at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
        at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)

2. Second invocation:

        at <Our runnable's run() method> 
        at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:178)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:454)
        at de.qfs.lib.gui.EventQueue.doDispatch(EventQueue.java:656)
        at
de.qfs.apps.qftest.client.TestEventQueue.doDispatch(TestEventQueue.java:240)
        at de.qfs.lib.gui.EventQueue.dispatchEvent(EventQueue.java:569)
        at
java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.ja
va:201)
        at
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java
:151)
        at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
        at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)

Note that in the "normal" case the event is dispatched at line
TestEventQueue.java:223, while the abnormal second case is coming from
TestEventQueue.java:240

What is also strange that we use SwingUtilities.invokeLater in a lot of
places but it looks like at the moment we have the problem with it only in
one particular place.

Of course it is easy to work around this particular problem just by adding
flag "alreadyExecuted" to the runnable, but what we do not want to do is to
add such a flag to _each_ place where we use SwingUtilities.invokeLater().

Everything points to a potential race condition in class TestEventQueue: for
some reasons sometimes it "forgets" that an event was already processed (?)

Has anybody else seen such a problem? 

Regards,

Leonid Kosmylev


-- 
The contents of this e-mail are intended for the named addressee only. It
contains information that may be confidential. Unless you are the named
addressee or an authorized designee, you may not copy or use it, or disclose
it to anyone else. If you received it in error please notify us immediately
and then destroy it. 



Videos Downloads Documentation Buy Free Trial