<AWT Dev> numAppContexts in AppContext modified in not-thread-safe way.
David Holmes
David.Holmes at oracle.com
Thu Aug 18 17:44:39 PDT 2011
Hi Clemens,
On 19/08/2011 10:34 AM, Clemens Eisserer wrote:
> Hi David,
>
> Part of the missing picture here is how AppContexts get created and
> dispose()'d as it may be that the way AppContext is used you can't
> actually get concurrent modification of numAppContexts. But there's no
> way to discern that from the AppContext code so it would be safer to use
> the AtomicInteger.
>
>
> I had a look how AppContexts are created, and at least the IcedTea plugin
> calls SunToolkit.createNewAppContext() in a fresh thread without any
> synchronization (as does caciocavallo-web).
> I don't this with all the code the non-atomicity of operations on
> numAppContexts is a real-world problem, but on the other hand - it wouldn't
> hurt to have this replaced with correct code ;)
Agreed.
Though it is also interesting to note that the only use of numAppContexts is
for the shortcut lookup of the main app context when numAppContexts==1. It's
not clear to me why this case needs to be handled specially. I also can't
tell what code would be calling getAppContext under those conditions.
Anyway, use of AtomicInteger is correct and should be "harmless".
Cheers,
David
More information about the awt-dev
mailing list