[jboss-jira] [JBoss JIRA] (AS7-5945) FreeBSD isThreadCpuTimeSupported

Alexander Yerenkow (JIRA) jira-events at lists.jboss.org
Mon Apr 15 05:21:53 EDT 2013


    [ https://issues.jboss.org/browse/AS7-5945?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12767144#comment-12767144 ] 

Alexander Yerenkow commented on AS7-5945:
-----------------------------------------

According to openJDK sources (both 6 & 7):
http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b14/sun/management/ThreadImpl.java#ThreadImpl.isThreadCpuTimeEnabled()


95     public boolean isThreadCpuTimeEnabled() {
96         if (!isThreadCpuTimeSupported() &&
97             !isCurrentThreadCpuTimeSupported()) {
98             throw new UnsupportedOperationException(
99                 "Thread CPU time measurement is not supported");
100        }
101        return cpuTimeEnabled;
102    }


this method (isThreadCpuTimeEnabled) mustn't called if both of isThreadCpuTimeSupported isCurrentThreadCpuTimeSupported returned false;

But, as can be seen in 
platform-mbean/src/test/java/org/jboss/as/platform/mbean/PlatformMBeanResourceUnitTestCase.java

    public void testThreadingMXBean() throws IOException {
...

//This call is unsafe, since it's neither prepended with checking of both isThreadCpuTimeSupported isCurrentThreadCpuTimeSupported aren't false, nor Exception catched.

        boolean threadCPUEnabled = describedResource.resource.get(PlatformMBeanConstants.THREAD_CPU_TIME_ENABLED).asBoolean();
        Assert.assertEquals(mbean.isThreadCpuTimeSupported(), threadCPUEnabled);


And here's log (If I correctly understood which one you asked for):

-------------------------------------------------------------------------------
Test set: org.jboss.as.platform.mbean.PlatformMBeanResourceUnitTestCase
-------------------------------------------------------------------------------
Tests run: 12, Failures: 1, Errors: 0, Skipped: 1, Time elapsed: 0.602 sec <<< FAILURE!
testThreadingMXBean(org.jboss.as.platform.mbean.PlatformMBeanResourceUnitTestCase)  Time elapsed: 0.007 sec  <<< FAILURE!
junit.framework.AssertionFailedError: thread-cpu-time-enabled is undefined
        at junit.framework.Assert.fail(Assert.java:50)
        at junit.framework.Assert.assertTrue(Assert.java:20)
        at org.jboss.as.platform.mbean.PlatformMBeanResourceUnitTestCase.validateResource(PlatformMBeanResourceUnitTestCase.java:591)
        at org.jboss.as.platform.mbean.PlatformMBeanResourceUnitTestCase.basicResourceTest(PlatformMBeanResourceUnitTestCase.java:559)
        at org.jboss.as.platform.mbean.PlatformMBeanResourceUnitTestCase.testThreadingMXBean(PlatformMBeanResourceUnitTestCase.java:336)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:616)
        at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
        at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
        at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
        at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
        at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
        at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
        at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
        at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
        at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
        at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
        at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
        at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30)
        at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
        at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:234)
        at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:133)
        at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:114)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:616)
        at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:188)
        at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:166)
        at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:86)
        at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:101)
        at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:74)


I hope this is enough to fix test to be run safely on FreeBSD ;)
                
> FreeBSD isThreadCpuTimeSupported
> --------------------------------
>
>                 Key: AS7-5945
>                 URL: https://issues.jboss.org/browse/AS7-5945
>             Project: Application Server 7
>          Issue Type: Feature Request
>          Components: Domain Management
>         Environment: FreeBSD 9.0-RELEASE-p3 FreeBSD 9.0-RELEASE-p3 #0: Tue Jun 12 02:52:29 UTC 2012     root at amd64-builder.daemonology.net:/usr/obj/usr/src/sys/GENERIC  amd64
> openjdk6/openjdk7
>            Reporter: Alexander Yerenkow
>             Fix For: 8.0.0.CR1
>
>
> Platform Tests should be modified, since it's not respecting when isThreadCpuTimeSupported = false (It continues run some test with isThreadCpuTimeSupported, which produces Exceptions, and all test failed);
> Simple test:
> ThreadMXBean threadMXBean = ManagementFactory.getThreadMXBean();
> System.out.println("threadMXBean.isThreadCpuTimeSupported() = " + threadMXBean.isThreadCpuTimeSupported());
> System.out.println("threadMXBean.isThreadCpuTimeEnabled() = " + threadMXBean.isThreadCpuTimeEnabled());
> Result:
> threadMXBean.isThreadCpuTimeSupported() = false
> Exception in thread "main" java.lang.UnsupportedOperationException: Thread CPU time measurement is not supported
>         at sun.management.ThreadImpl.isThreadCpuTimeEnabled(ThreadImpl.java:98)
>         at Test.main(Test.java:19)

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira


More information about the jboss-jira mailing list