nikunjagarwal321 opened a new pull request, #5527: URL: https://github.com/apache/hive/pull/5527
### What changes were proposed in this pull request? Sorting the fields in function `getDeclaredNonStaticFields()` in ObjectInspectorUtils.java class in order to make the function deterministic. The below flaky tests will be fixed by this. ### Why are the changes needed? Multiple flaky tests were detected in _serde_ module while trying to run the tests using the nondex tool. [NonDex](https://github.com/TestingResearchIllinois/NonDex) is a tool for detecting and debugging wrong assumptions on under-determined Java APIs. #### Steps to reproduce flakiness using nondex - ``` mvn install -pl serde -DskipTests mvn -pl serde test -Dtest=org.apache.hadoop.hive.serde2.objectinspector.TestProtocolBuffersObjectInspectors#testProtocolBuffersObjectInspectors mvn -pl serde edu.illinois:nondex-maven-plugin:2.1.7:nondex -Dtest=org.apache.hadoop.hive.serde2.objectinspector.TestProtocolBuffersObjectInspectors#testProtocolBuffersObjectInspectors ``` #### ERROR logs: ``` [ERROR] Failures: [ERROR] TestProtocolBuffersObjectInspectors.testProtocolBuffersObjectInspectors:71 expected:<test> but was:<[one, two]> ``` <img width="1021" alt="Screenshot 2024-11-02 at 2 48 35 PM" src="https://github.com/user-attachments/assets/0ffae340-4d5f-4deb-94af-1742474c2adf"> ### Reason for Failure The method **getDeclaredNonStaticFields(Class<?> c)** in class **ObjectInspectorUtils.java** uses class.getDeclaredFields() method which is nondeterministic as per [java docs](https://docs.oracle.com/javase/8/docs/api/java/lang/Class.html#getDeclaredFields--). ` Field[] f = c.getDeclaredFields();` <img width="705" alt="Screenshot 2024-11-02 at 4 26 58 PM" src="https://github.com/user-attachments/assets/9d4a43ea-7bca-4679-ba1a-7d3a7672c221"> As per the test cases, it is assumed that the return order of the fields will always be the same, which may not be the case. All the below test cases are impacted because of the same reason : - org.apache.hadoop.hive.serde2.objectinspector.TestProtocolBuffersObjectInspectors.testProtocolBuffersObjectInspectors - org.apache.hadoop.hive.serde2.objectinspector.TestThriftObjectInspectors.testThriftObjectInspectors - org.apache.hadoop.hive.serde2.objectinspector.TestReflectionObjectInspectors.testReflectionObjectInspectors - org.apache.hadoop.hive.serde2.columnar.TestLazyBinaryColumnarSerDe.testLazyBinaryColumnarSerDeWithEmptyBinary - org.apache.hadoop.hive.serde2.columnar.TestLazyBinaryColumnarSerDe.testSerDeInnerNulls - org.apache.hadoop.hive.serde2.lazybinary.TestLazyBinarySerDe.testLazyBinarySerDe - org.apache.hadoop.hive.serde2.TestStatsSerde.testLazyBinarySerDe - org.apache.hadoop.hive.serde2.lazy.TestLazySimpleSerDe#testSerDeParameters - org.apache.hadoop.hive.serde2.binarysortable.TestBinarySortableSerDe#testBinarySortableSerDe ### Does this PR introduce _any_ user-facing change? No ### Is the change a dependency upgrade? No ### How was this patch tested? The changes were tested by running the unit tests locally. The code is already covered in the above test cases and is actually fixing the flaky tests. Please let me know if you have any questions or would like to discuss this further for any clarificaitions. -- 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. To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org For additional commands, e-mail: gitbox-h...@hive.apache.org