preko-p opened a new pull request, #11002: URL: https://github.com/apache/seatunnel/pull/11002
### Purpose of this pull request Fixes #10999. This PR prevents `MongodbReader.closeCurrentSplit()` from masking the original MongoDB cursor creation failure with a cleanup-path `NullPointerException`. When `getCursor(currentSplit)` fails before assigning `cursor`, `pollNext()` still runs `closeCurrentSplit()` in the `finally` block. The previous `Preconditions.checkNotNull(cursor)` could throw a new `NullPointerException` and hide the real MongoDB connection, auth, or query error. The cleanup path now returns when no cursor exists and preserves the original failure. ### Does this PR introduce _any_ user-facing change? Yes. When MongoDB cursor creation fails, users should now see the original MongoDB connector failure instead of a misleading cleanup `NullPointerException`. There is no connector option, API, packaging, or documented configuration change. ### How was this patch tested? Added unit coverage in `MongodbReaderTest`: - `pollNextPreservesOriginalCursorCreationException()` verifies the original cursor creation exception is preserved. - `pollNextClosesCursorWhenDeserializationFails()` verifies an already-created cursor is still closed when downstream deserialization fails. Local verification: ```bash ./mvnw -pl seatunnel-connectors-v2/connector-mongodb -DskipITs -DskipIT -DskipE2E -DskipTests=false -DfailIfNoTests=false -Dtest=MongodbReaderTest test ./mvnw -pl seatunnel-connectors-v2/connector-mongodb -DskipITs -DskipIT -DskipE2E -DskipTests=false -DfailIfNoTests=false test ./mvnw -pl seatunnel-connectors-v2/connector-mongodb spotless:check git diff --check ``` Results: - Targeted reader tests: 2 passed. - MongoDB connector module tests: 12 passed. - Spotless: passed. - Diff whitespace check: passed. ### Check list * [x] No new Jar binary package is added by this PR. * [x] Documentation update is not necessary because this is an internal bug fix with no connector option or usage change. * [x] `incompatible-changes.md` update is not necessary because this does not introduce an incompatibility. * [x] Existing connector metadata, distribution POM, label scope, E2E, and plugin config updates are not necessary because this fixes an existing MongoDB connector reader cleanup path and does not add a new connector or packaging surface. -- 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]
