<Swing Dev> Is the following code supposed to leak?
Clemens Eisserer
linuxhippy at gmail.com
Thu Aug 25 19:20:41 UTC 2011
Hi Pavel,
So if your SecurityManager denies app closing, then the application should
> be alive. It looks that your implementation contradicts javadoc contracts.
>
The app stays running for as long as the client's browser window is open -
and is terminated when the assicioated HttpSession times out.
This is when we dispose the AppContexts, which closes this one app
"instance".
> Besides, I find it a bit weird that addXZYListener() secretly registers
>> listener to some sort of internal global object. That sounds very leaky.
>> Is it documented that such listeners must always be carefully removed?
>> Or am I missing something?
>>
> As I said normally listeners shouldn't be removed manually, until this
> listeners are added to static instances (or delegates). The
> JTextComponent#getActions method invoked on non-static object, but it uses
> inside static editor kit. So listener removing depends on implementation and
> programmers should take such nuances into account.
>
I think what Roman ment is wether this is documented somewhere - I couldn't
find out why the code leaked until I had a look at Swing's source.
I find the current API quite unintuitive - I register a listener to a
JTextArea's editor, which sends me events just for this one JTextArea, and
jet its added to some global state. From what I have seen the editors are
mostly a bunch of state-less code, except for the Actions defined.
Any compatibility-issues in mind re-working that area, making the actions
part of the JComponent's state?
Thanks, Clemens
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/swing-dev/attachments/20110825/7f7cf32f/attachment.html>
More information about the swing-dev
mailing list