-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Description
Search before reporting
- I searched in the issues and found nothing similar.
Read release policy
- I understand that unsupported 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, 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
I discovered the problem with the 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
https://gist.github.com/LucasEby/070433176e275c51d4ae664b27985756
Reproducing the issue
You can replicate the problem with the 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?
- I'm willing to submit a PR!