LucasEby opened a new issue, #24806: URL: https://github.com/apache/pulsar/issues/24806
### Search before reporting - [x] I searched in the [issues](https://github.com/apache/pulsar/issues) and found nothing similar. ### Read release policy - [x] I understand that [unsupported versions](https://pulsar.apache.org/contribute/release-policy/#supported-versions) don't get bug fixes. I will attempt to reproduce the issue on a supported version of Pulsar client and Pulsar broker. ### User environment Broker version: 4.2.0-SNAPSHOT Broker Operating system and hardware type: Linux x86_64 GNU/Linux Broker Java version: 17.0.16 ### Issue Description In ProtobufSchemaTest.testParsingInfoProperty, the json's contents and the \_\_PARSING\_INFO\_\_ field's contents do not have a deterministic order but the hardcoded string assertion assumes a deterministic order. Serializing a map to a JSON with ```new ObjectMapper().writeValueAsString(schema.getSchemaInfo().getProperties())``` can change the order of the keys since attribute order is not guaranteed in JSON. Additionally the inner JSON string order in \_\_PARSING\_INFO\_\_ can vary for the same reason. The ordering in both cases can change due to different environments producing the contents in different orders despite the logical contents being the same. Since the test compares the raw strings/trees "as-is", harmless re-ordering could flip the test from pass to fail despite the data being semantically the same. I discovered the problem with the [NonDex](https://github.com/TestingResearchIllinois/NonDex) tool. NonDex systematically detects incorrect tests that rely on non-deterministic behaviors in Java APIs—like assuming order of name/value pairs in json files — by exploring all specification-allowed outcomes. It does this by instrumenting undetermined APIs and randomizing the returned order/behavior within what the spec allows. Failures it exposes reliably indicate flawed assumptions in order that were never promised and should be fixed. ### Error messages ```text [ERROR] Failures: [ERROR] org.apache.pulsar.client.impl.schema.ProtobufSchemaTest.testParsingInfoProperty [INFO] Run 1: PASS [ERROR] Run 2: ProtobufSchemaTest.testParsingInfoProperty:123 expected [{"__alwaysAllowNull":"true","__jsr310ConversionEnabled":"false","__PARSING_INFO__":"[{\"number\":1,\"name\":\"stringField\",\"type\":\"STRING\",\"label\":\"LABEL_OPTIONAL\",\"definition\":null},{\"number\":2,\"name\":\"doubleField\",\"type\":\"DOUBLE\",\"label\":\"LABEL_OPTIONAL\",\"definition\":null},{\"number\":6,\"name\":\"intField\",\"type\":\"INT32\",\"label\":\"LABEL_OPTIONAL\",\"definition\":null},{\"number\":4,\"name\":\"testEnum\",\"type\":\"ENUM\",\"label\":\"LABEL_OPTIONAL\",\"definition\":null},{\"number\":5,\"name\":\"nestedField\",\"type\":\"MESSAGE\",\"label\":\"LABEL_OPTIONAL\",\"definition\":null},{\"number\":10,\"name\":\"repeatedField\",\"type\":\"STRING\",\"label\":\"LABEL_REPEATED\",\"definition\":null},{\"number\":11,\"name\":\"externalMessage\",\"type\":\"MESSAGE\",\"label\":\"LABEL_OPTIONAL\",\"definition\":null}]"}] but found [{"__PARSING_INFO__":"[{\"type\":\"STRING\",\"definition\" :null,\"number\":1,\"label\":\"LABEL_OPTIONAL\",\"name\":\"stringField\"},{\"type\":\"DOUBLE\",\"definition\":null,\"number\":2,\"label\":\"LABEL_OPTIONAL\",\"name\":\"doubleField\"},{\"type\":\"INT32\",\"definition\":null,\"number\":6,\"label\":\"LABEL_OPTIONAL\",\"name\":\"intField\"},{\"type\":\"ENUM\",\"definition\":null,\"number\":4,\"label\":\"LABEL_OPTIONAL\",\"name\":\"testEnum\"},{\"type\":\"MESSAGE\",\"definition\":null,\"number\":5,\"label\":\"LABEL_OPTIONAL\",\"name\":\"nestedField\"},{\"type\":\"STRING\",\"definition\":null,\"number\":10,\"label\":\"LABEL_REPEATED\",\"name\":\"repeatedField\"},{\"type\":\"MESSAGE\",\"definition\":null,\"number\":11,\"label\":\"LABEL_OPTIONAL\",\"name\":\"externalMessage\"}]","__jsr310ConversionEnabled":"false","__alwaysAllowNull":"true"}] [INFO] [INFO] [ERROR] Tests run: 1, Failures: 1, Errors: 0, Skipped: 0 [INFO] INFO: Surefire failed when running tests for mwRi4EiPs9OrPIcZpGSzXLfQKeVy4tzuIVHtHDAtRys= [INFO] NonDex SUMMARY: [INFO] ********* [INFO] mvn nondex:nondex -DnondexFilter='.*' -DnondexMode=FULL -DnondexSeed=974622 -DnondexStart=0 -DnondexEnd=9223372036854775807 -DnondexPrintstack=false -DnondexDir="/home/leby2/pulsar/pulsar-client/.nondex" -DnondexJarDir="/home/leby2/pulsar/pulsar-client/.nondex" -DnondexExecid=mwRi4EiPs9OrPIcZpGSzXLfQKeVy4tzuIVHtHDAtRys= -DnondexLogging=CONFIG [WARNING] org.apache.pulsar.client.impl.schema.ProtobufSchemaTest#testParsingInfoProperty [INFO] ********* [INFO] All tests pass without NonDex shuffling [INFO] #################### [INFO] Across all seeds: [INFO] org.apache.pulsar.client.impl.schema.ProtobufSchemaTest#testParsingInfoProperty [INFO] Test results can be found at: [INFO] file:///home/leby2/pulsar/pulsar-client/.nondex/mwRi4EiPs9OrPIcZpGSzXLfQKeVy4tzuIVHtHDAtRys=/test_results.html [INFO] [NonDex] The id of this run is: mwRi4EiPs9OrPIcZpGSzXLfQKeVy4tzuIVHtHDAtRys= [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE ``` ### Reproducing the issue You can replicate the problem with the [NonDex](https://github.com/TestingResearchIllinois/NonDex) tool command: ```mvn -pl pulsar-client -Dtest=org.apache.pulsar.client.impl.schema.ProtobufSchemaTest#testParsingInfoProperty -DforkCount=1 -DnondexSeed=974622 -DnondexRuns=1 -DreuseForks=false edu.illinois:nondex-maven-plugin:2.2.1:nondex``` ### Additional information _No response_ ### Are you willing to submit a PR? - [x] I'm willing to submit a PR! -- 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]
