annhchen89 opened a new pull request, #5947: URL: https://github.com/apache/accumulo/pull/5947
### What does this PR do? This PR is fixing a nondeterministic test failure in ```MetadataConstraintsTest.testDataFileCheck()``` when running with [NonDex](https://github.com/TestingResearchIllinois/NonDex) ### Problem Within testDataFileCheck() — specifically the case "Bad Json - test path value missing" — the test previously relied on a regex replacement against the JSON string returned by: ``` StoredTabletFile.of(path).getMetadata().replaceFirst("\"path\":\".*\",\"startRow", "\"path\":\"\",\"startRow")``` When the test uses StoredTabletFile.of(Path), the constructor path eventually calls serialize(fileCq), which invokes gson.toJson(metadata) to produce the metadata JSON. Gson serializes plain Java objects (POJOs) by reflecting over their declared fields. Under the hood, it uses the JDK’s reflection APIs (such as Class.getDeclaredFields()) to discover which fields exist in a class. The JDK specification for these APIs explicitly states: “The elements in the array returned are not sorted and are not in any particular order.” This means the field order returned by reflection is undefined, so Gson may serialize them in different sequences depending on the JVM or when shuffled by tools like NonDex. As a result, "path" doesn’t always come before "startRow", breaking the test’s regex and causing nondeterministic failures. ### Reproduce Test To reproduce the failing test, Nondex can be used. ```mvn -pl server/base edu.illinois:nondex-maven-plugin:2.2.1:nondex -DnondexRuns=10 -Denforcer.skip=true -Dtest=org.apache.accumulo.server.constraints.MetadataConstraintsTest#testDataFileCheck``` ### The Fix Instead of applying a regex that assumes field order, the test now parses the JSON into a JsonObject and explicitly clears the "path" field. This ensures that the "path" field is always set to an empty string — as the test intended for the “Bad Json” case — regardless of serialization order. -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
