Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix get declared fields dependent test #473

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Fix get declared fields dependent test #473

wants to merge 4 commits into from

Conversation

shunfan-shao
Copy link

Description

Test org.apache.cayenne.reflect.PojoMapperTest.testObjectCreation will fail under 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:

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, 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant