You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "ASF GitHub Bot (Jira)" <ji...@apache.org> on 2019/11/23 22:54:00 UTC

[jira] [Work logged] (LANG-1501) Test may fail due to a different order of fields returned by reflection api

     [ https://issues.apache.org/jira/browse/LANG-1501?focusedWorklogId=348619&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-348619 ]

ASF GitHub Bot logged work on LANG-1501:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 23/Nov/19 22:53
            Start Date: 23/Nov/19 22:53
    Worklog Time Spent: 10m 
      Work Description: contextshuffling commented on pull request #481: [LANG-1501] Sort fields in ReflectionToStringBuilder for deterministic order
URL: https://github.com/apache/commons-lang/pull/481
 
 
   This fixes [LANG-1501](https://issues.apache.org/jira/projects/LANG/issues/LANG-1501?filter=allissues).
   
   In this PR, it proposes:
   * Sort the fields with their names for a deterministic order (alphabetical)
   * Modify some test assertions to match the behavior
   
 
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Issue Time Tracking
-------------------

            Worklog Id:     (was: 348619)
    Remaining Estimate: 0h
            Time Spent: 10m

> Test may fail due to a different order of fields returned by reflection api
> ---------------------------------------------------------------------------
>
>                 Key: LANG-1501
>                 URL: https://issues.apache.org/jira/browse/LANG-1501
>             Project: Commons Lang
>          Issue Type: Bug
>          Components: lang.builder.*
>            Reporter: contextshuffling
>            Priority: Minor
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> Tests in MultilineRecursiveToStringStyleTest.java, RecursiveToStringStyleTest.java, ToStringBuilderTest.java depends on ReflectionToStringBuilder.appendFieldsIn. It appends the fields returned by java.lang.Class.getDeclaredFields. 
> However, java.lang.Class.getDeclaredFields does not guarantee any specific order and thus, test can fail if the order is different, (i.e., it generates a different hash code). "The elements in the returned array are not sorted and are not in any particular order" (reference: https://docs.oracle.com/javase/8/docs/api/java/lang/Class.html#getDeclaredMethods--)



--
This message was sent by Atlassian Jira
(v8.3.4#803005)