T
Twisted
I may have discovered another bug in the 1.6.0 release candidate
library implementation.
I mentioned earlier that my app's "are you sure?" on-exit dialog was
suddenly popping up twice. I've since found it popping up only once, as
it should, under a well-defined set of circumstances that prove the
culprit to be one of two occurrences of:
if (frame.getWindowListeners().length > 0)
frame.removeWindowListener(frame.getWindowListeners()[0]);
This used to work -- the window always has exactly the one window
listener if it has any, and it's sometimes removed and replaced with a
different one, and all of this activity is restricted to the event
dispatch thread so there are no concurrency issues.
Now we have a clear case of where this fails exactly once. The app adds
an initial window listener, and at a later time when there's some
cleanup to be done on exit it replaces that one with a different one.
If the cleanup stops being needed, it replaces it again. Although the
code in that replace is identical to the code in the first, I expect
javac is probably dumb enough to create two different anonymous inner
classes for these, so the third and the first aren't the same class as
the JVM sees it.
So listener 1 is added, then removed and 2 added, then 2 removed and 3
added, 3 removed and 2 added, 2 removed and 3 added, and so forth. Or
so it used to go. Now, one of them (perhaps listener 1) lingers
forever.
Either adding the first window listener doesn't cause
frame.getWindowListeners().length > 0, or
frame.removeWindowListener(frame.getWindowListeners()[0]) simply
doesn't work properly. I'm guessing the former -- add listener 1 and
the array remains empty; add listener 2 and it grows an element; remove
it and add listener 3 works as it should; remove that and put 2 back
works as it should; and so forth.
Anyone else encountering this?
library implementation.
I mentioned earlier that my app's "are you sure?" on-exit dialog was
suddenly popping up twice. I've since found it popping up only once, as
it should, under a well-defined set of circumstances that prove the
culprit to be one of two occurrences of:
if (frame.getWindowListeners().length > 0)
frame.removeWindowListener(frame.getWindowListeners()[0]);
This used to work -- the window always has exactly the one window
listener if it has any, and it's sometimes removed and replaced with a
different one, and all of this activity is restricted to the event
dispatch thread so there are no concurrency issues.
Now we have a clear case of where this fails exactly once. The app adds
an initial window listener, and at a later time when there's some
cleanup to be done on exit it replaces that one with a different one.
If the cleanup stops being needed, it replaces it again. Although the
code in that replace is identical to the code in the first, I expect
javac is probably dumb enough to create two different anonymous inner
classes for these, so the third and the first aren't the same class as
the JVM sees it.
So listener 1 is added, then removed and 2 added, then 2 removed and 3
added, 3 removed and 2 added, 2 removed and 3 added, and so forth. Or
so it used to go. Now, one of them (perhaps listener 1) lingers
forever.
Either adding the first window listener doesn't cause
frame.getWindowListeners().length > 0, or
frame.removeWindowListener(frame.getWindowListeners()[0]) simply
doesn't work properly. I'm guessing the former -- add listener 1 and
the array remains empty; add listener 2 and it grows an element; remove
it and add listener 3 works as it should; remove that and put 2 back
works as it should; and so forth.
Anyone else encountering this?