You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-issues@hadoop.apache.org by "Hudson (Jira)" <ji...@apache.org> on 2020/03/02 18:09:00 UTC

[jira] [Commented] (HADOOP-16897) Sort fields in ReflectionUtils.java

    [ https://issues.apache.org/jira/browse/HADOOP-16897?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17049508#comment-17049508 ] 

Hudson commented on HADOOP-16897:
---------------------------------

SUCCESS: Integrated in Jenkins build Hadoop-trunk-Commit #18020 (See [https://builds.apache.org/job/Hadoop-trunk-Commit/18020/])
HADOOP-16897. Sort fields in ReflectionUtils.java. (github: rev 5678b19b016934fecfb16177c849668d642c9c7a)
* (edit) hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/ReflectionUtils.java


> 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-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-issues-help@hadoop.apache.org