[ https://issues.apache.org/jira/browse/HADOOP-16897?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Steve Loughran resolved HADOOP-16897. ------------------------------------- Resolution: Fixed fixed in trunk -thanks! > Sort fields in ReflectionUtils.java > ----------------------------------- > > Key: HADOOP-16897 > URL: https://issues.apache.org/jira/browse/HADOOP-16897 > Project: Hadoop Common > Issue Type: Bug > Components: test, util > Affects Versions: 3.3.0 > Reporter: cpugputpu > Assignee: cpugputpu > Priority: Minor > Fix For: 3.3.0 > > > The tests in > _org.apache.hadoop.metrics2.impl.TestMetricsSystemImpl#testInitFirstVerifyCallBacks_ > and > _org.apache.hadoop.metrics2.impl.TestMetricsSystemImpl#testInitFirstVerifyStopInvokedImmediately_ > can fail. > java.lang.AssertionError: > Element 0 for metrics expected:<MetricCounterLong{info=MetricsInfoImpl > {name=C1, description=C1 desc} > , value=1}> > but was:<MetricGaugeLong{info=MetricsInfoImpl > {name=G1, description=G1 desc} > , value=2}> > at org.junit.Assert.fail(Assert.java:88) > at org.junit.Assert.failNotEquals(Assert.java:834) > at org.junit.Assert.assertEquals(Assert.java:118) > at org.apache.hadoop.test.MoreAsserts.assertEquals(MoreAsserts.java:60) > at > org.apache.hadoop.metrics2.impl.TestMetricsSystemImpl.checkMetricsRecords(TestMetricsSystemImpl.java:439) > at > org.apache.hadoop.metrics2.impl.TestMetricsSystemImpl.testInitFirstVerifyCallBacks(TestMetricsSystemImpl.java:178) > > The root cause of this failure can be analyzed in the following stack trace: > _java.lang.Class.*getDeclaredFields*(Class.java:1916)_ > > _org.apache.hadoop.util.ReflectionUtils.getDeclaredFieldsIncludingInherited(ReflectionUtils.java:353)_ > > _org.apache.hadoop.metrics2.lib.MetricsSourceBuilder.<init>(MetricsSourceBuilder.java:68)_ > > _org.apache.hadoop.metrics2.lib.MetricsAnnotations.newSourceBuilder(MetricsAnnotations.java:43)_ > > _org.apache.hadoop.metrics2.impl.MetricsSystemImpl.register(MetricsSystemImpl.java:223)_ > > _org.apache.hadoop.metrics2.impl.TestMetricsSystemImpl.testInitFirstVerifyCallBacks(TestMetricsSystemImpl.java:156)_ > The specification about getDeclaredFields() says that "the elements in the > returned array are not sorted and are not in any particular order". The > documentation is here for your reference: > [https://docs.oracle.com/javase/8/docs/api/java/lang/Class.html#getDeclaredFields--] > And the behaviour might be different for different JVM versions or vendors > > The fix is to sort the fields returned by getDeclaredFields() so that the > non-deterministic behaviour can be eliminated completely. In this way, the > test becomes more stable and it will not suffer from the failure above any > more. > > > > -- This message was sent by Atlassian Jira (v8.3.4#803005) --------------------------------------------------------------------- To unsubscribe, e-mail: common-dev-unsubscr...@hadoop.apache.org For additional commands, e-mail: common-dev-h...@hadoop.apache.org