You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by GitBox <gi...@apache.org> on 2021/11/23 02:54:54 UTC

[GitHub] [cayenne] shunfan-shao opened a new pull request #473: Fix get declared fields dependent test

shunfan-shao opened a new pull request #473:
URL: https://github.com/apache/cayenne/pull/473


   # Description
   Test `org.apache.cayenne.reflect.PojoMapperTest.testObjectCreation` will fail under [NonDex](https://github.com/TestingResearchIllinois/NonDex) which detects flakiness under non-deterministic environment. 
   
   To reproduce:
   ```
   mvn edu.illinois:nondex-maven-plugin:1.1.2:nondex \
       -pl cayenne-server \
       -Dtest=org.apache.cayenne.reflect.PojoMapperTest#testObjectCreation
   ```
   
   # Issue
   In `testObjectCreation`, the object creation depends on the following logic:
   ```java
   Field[] declaredFields = type.getDeclaredFields();
   this.setters = new MethodHandle[declaredFields.length];
   int i = 0;
   for(Field field : declaredFields) {
           ...
           setters[i++] = lookup.unreflectSetter(field);
   }
   ```
   
   However, according to the documentation of [getDeclaredFields](https://docs.oracle.com/javase/8/docs/api/java/lang/Class.html#getDeclaredFields--), the function does not guarantee the order of fields and may be different on different JVM. 
   
   Simply applying sorting on the fields could guarantee correctness in the testing environment. 


-- 
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: commits-unsubscribe@cayenne.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org