LucasEby opened a new issue, #24869: URL: https://github.com/apache/pulsar/issues/24869
### 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 below tests utilized a helper test method (called test) which incorrectly assumed that the json key-value pairs in responseBody would have a deterministic order. The order of key-value pairs is not guaranteed in [JSON](https://www.json.org/json-en.html), however. As a result, the ordering can change due to different environments producing the contents in different orders despite the logical contents being the same. Each of the tests below used this helper to compare the responseBody "as-is" with an incorrect equals method so hardmless re-ordering could flip the tests from pass to fail despite the data being semantically the same. - `org.apache.pulsar.io.http.HttpSinkTest#testGenericRecord` - `org.apache.pulsar.io.http.HttpSinkTest#testKeyValueGenericRecord` - `org.apache.pulsar.io.http.HttpSinkTest#testKeyValuePrimitives` - `org.apache.pulsar.io.http.HttpSinkTest#testKeyValueGenericRecord` 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 https://gist.github.com/LucasEby/070433176e275c51d4ae664b27985756 ``` ### Reproducing the issue You can replicate the problem with the [NonDex](https://github.com/TestingResearchIllinois/NonDex) tool commands: ``` mvn -pl pulsar-io/http -Dtest=org.apache.pulsar.io.http.HttpSinkTest#testGenericRecord -DnondexSeed=974622 edu.illinois:nondex-maven-plugin:2.2.1:nondex ``` ``` mvn -pl pulsar-io/http -Dtest=org.apache.pulsar.io.http.HttpSinkTest#testKeyValueGenericRecord -DnondexSeed=974622 edu.illinois:nondex-maven-plugin:2.2.1:nondex ``` ``` mvn -pl pulsar-io/http -Dtest=org.apache.pulsar.io.http.HttpSinkTest#testKeyValuePrimitives -DnondexSeed=1306174 -DnondexRuns=1 -DforkCount=1 -DreuseForks=false edu.illinois:nondex-maven-plugin:2.2.1:nondex ``` ``` mvn -pl pulsar-io/http -Dtest=org.apache.pulsar.io.http.HttpSinkTest#testKeyValueGenericRecord -DnondexSeed=974622 -DnondexRuns=1 -DforkCount=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]
