LucasEby opened a new issue, #24820: URL: https://github.com/apache/pulsar/issues/24820
### 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 Each of the tests below were written with the assumption that the json key-value pairs would have a deterministic order (by comparing json results vs hard coded strings). The order of key-value pairs is not guaranteed in [JSON files](https://www.json.org/json-en.html) or [JSON objects](https://docs.oracle.com/javaee/7/api/javax/json/JsonObject.html), though. As a result, the ordering can change due to different environments producing the contents in different orders despite the logical contents being the same. Since each of the tests below compare the raw strings/trees "as-is", harmless re-ordering could flip the test from pass to fail despite the data being semantically the same. - `org.apache.pulsar.common.policies.data.NamespaceOwnershipStatusTest#testSerialization` - `org.apache.pulsar.common.policies.impl.NamespaceIsolationPoliciesTest#testJsonSerialization` - `org.apache.pulsar.functions.utils.FunctionConfigUtilsTest#testConvertBackFidelity` - `org.apache.pulsar.functions.utils.SinkConfigUtilsTest#testConvertBackFidelity` - `org.apache.pulsar.functions.utils.SourceConfigUtilsTest#testBatchConfigMergeEqual ` - `org.apache.pulsar.io.elasticsearch.ElasticSearchExtractTest#testGenericRecord` - `org.apache.pulsar.io.kinesis.UtilsTest#testKeyValueSerializeNoValue`. 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. Note: I created a single issue at the advice here: https://github.com/apache/pulsar/discussions/24808 ### Error messages ```text https://gist.github.com/LucasEby/0d9dc227f3b835527078245672f31efa ``` ### Reproducing the issue You can replicate the problem with the [NonDex](https://github.com/TestingResearchIllinois/NonDex) tool commands: ```mvn -pl pulsar-common -Dtest=org.apache.pulsar.common.policies.data.NamespaceOwnershipStatusTest#testSerialization -DforkCount=1 -DnondexSeed=1016066 -DnondexRuns=1 -DreuseForks=false edu.illinois:nondex-maven-plugin:2.2.1:nondex``` ```mvn -pl pulsar-common -Dtest=org.apache.pulsar.common.policies.impl.NamespaceIsolationPoliciesTest#testJsonSerialization -DforkCount=1 -DnondexSeed=1057510 -DnondexRuns=1 -DreuseForks=false edu.illinois:nondex-maven-plugin:2.2.1:nondex``` ```mvn -pl pulsar-functions/utils -Dtest=org.apache.pulsar.functions.utils.FunctionConfigUtilsTest#testConvertBackFidelity -DforkCount=1 -DnondexSeed=1016066 -DnondexRuns=1 -DreuseForks=false edu.illinois:nondex-maven-plugin:2.2.1:nondex``` ```mvn -pl pulsar-functions/utils -Dtest=org.apache.pulsar.functions.utils.SinkConfigUtilsTest#testConvertBackFidelity -DforkCount=1 -DnondexSeed=974622 -DnondexRuns=1 -DreuseForks=false edu.illinois:nondex-maven-plugin:2.2.1:nondex``` ```mvn -pl pulsar-functions/utils -Dtest=org.apache.pulsar.functions.utils.SourceConfigUtilsTest#testBatchConfigMergeEqual -DforkCount=1 -DnondexSeed=974622 -DnondexRuns=1 -DreuseForks=false edu.illinois:nondex-maven-plugin:2.2.1:nondex``` ```mvn -pl pulsar-io/elastic-search -Dtest=org.apache.pulsar.io.elasticsearch.ElasticSearchExtractTest#testGenericRecord -DforkCount=1 -DnondexSeed=974622 -DnondexRuns=1 -DreuseForks=false edu.illinois:nondex-maven-plugin:2.2.1:nondex``` ```mvn -pl pulsar-io/kinesis -Dtest=org.apache.pulsar.io.kinesis.UtilsTest#testKeyValueSerializeNoValue -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]
