RFR (JAXP) JDK-8163468: javax/xml/jaxp/unittest/validation/Bug6773084Test.java fails intermittently
Frank Yuan
frank.yuan at oracle.com
Thu Aug 11 03:30:52 UTC 2016
Hi Daniel
Thank you very much for review!
> -----Original Message-----
> From: Daniel Fuchs [mailto:daniel.fuchs at oracle.com]
> Subject: Re: RFR (JAXP) JDK-8163468: javax/xml/jaxp/unittest/validation/Bug6773084Test.java fails intermittently
>
> Hi Frank,
>
> Good analysis of the failure root cause!
>
> The proposed fix looks good to me.
>
> As a side note, are there other multi-threaded tests in JAXP?
>
I searched yesterday, there is no other such issue in jaxp tests. E.g. common.WarningsTestBase also starts multiple threads in its
test method, but it already awaitTermination in the test method. Another one is stream.Bug6688002Test, which uses Thread.join() in
its test method.
> If so maybe you'll need a special method in JAXPSecurityManager
> to transfer the permissions of the current to another thread
> (I mean - find a way to make the other thread run its
> runnable in a similar runWithTmpPermission(...) call
> than the main thread, I believe InheritableThreadLocal would not
> be appropriate nor sufficient for that).
>
Because the System SecurityManager and the java.security.Policy instance are global, the children threads have the same SM and
Policy as the main thread. In this test failure, the childrent threads had enough permission until TestNG invoked onFinish(because
the code in test method finished), in the call-back function JAXPPolicyManager restored the default SM and Policy, which had no
enough permission. In the race condition, children thread got a non-null SecurityManager and then got the default Policy.
So the challenge is how to keep the TestPolicy till the children threads finish. I can use a read-write lock, the children threads
hold the read lock and JAXPPolicyManager needs to get the write lock before it sets SM and Policy, but this is actually equivalent
to Thread.join() in the test method, and I think it's reasonable to wait for all children threads finished in the test method.
This test failure is very frequent in Mach5, since current proposed fix is also OK to you and Joe, I pushed it at first :)
Thanks
Frank
> JAXP multi-threaded tests might need to be revisited with that
> in mind.
>
> best regards,
>
> -- daniel
>
>
> On 10/08/16 09:06, Frank Yuan wrote:
> > Hi,
> >
> >
> >
> > Would you like to review http://cr.openjdk.java.net/~fyuan/8163468/webrev.00/
> >
> > It is to fix https://bugs.openjdk.java.net/browse/JDK-8163468
> >
> >
> >
> > Please check the bug comment for the root cause, this patch moved the code which requires file permission to the main test
method,
> > that can guarantee to have the permission. And try to wait the children threads to complete in the main test method, that make
the
> > test method more graceful.
> >
> >
> >
> >
> >
> > Thanks
> >
> > Frank
> >
More information about the core-libs-dev
mailing list