You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@seatunnel.apache.org by "zab-oza (via GitHub)" <gi...@apache.org> on 2026/06/03 03:32:36 UTC

[I] MongoDB connector closeCurrentSplit() masks real errors with NullPointerException [seatunnel]

zab-oza opened a new issue, #10999:
URL: https://github.com/apache/seatunnel/issues/10999

   ## Summary
   
   If the MongoDB source connector fails to create a cursor (due to connection, auth, or query error), the `closeCurrentSplit()` method in `MongodbReader.java` always throws a `NullPointerException`, masking the root MongoDB error. This affects jobs where parallelism > 1 or where only a single small split is generated. The outcome is that the real error never appears in logs—only the masking NPE.
   
   ## Steps to Reproduce
   - Use SeaTunnel 2.3.13
   - Configure a MongoDB source with Zeta engine, parallelism > 1
   - Have a small collection or cause a MongoDB connection/query failure
   - Observe the stack trace:
   
   ```
   java.lang.NullPointerException at org.apache.seatunnel.shade.com.google.common.base.Preconditions.checkNotNull(Preconditions.java:877)
     at org.apache.seatunnel.connectors.seatunnel.mongodb.source.reader.MongodbReader.closeCurrentSplit(MongodbReader.java:153)
     at org.apache.seatunnel.connectors.seatunnel.mongodb.source.reader.MongodbReader.pollNext(MongodbReader.java:104)
   ```
   
   ## Impact
   - Users and deployers see an NPE and cannot diagnose the *actual* MongoDB connector problem.
   - Real database issues are hidden, causing confusion and unnecessary debug time.
   
   ## Recommended Fix
   Add a null check before attempting to close the cursor:
   ```java
   private void closeCurrentSplit() {
       if (cursor != null) {
           cursor.close();
           cursor = null;
       }
   }
   ```
   
   ## Additional Notes
   Several downstream mitigations are helpful (force parallelism=1, set split-size high, run schema discovery before job submission) but do not address the issue for all cases.
   
   A connector-side fix is required to allow real MongoDB errors to surface and avoid masking them with a NullPointerException.


-- 
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: commits-unsubscribe@seatunnel.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] MongoDB connector closeCurrentSplit() masks real errors with NullPointerException [seatunnel]

Posted by "DanielLeens (via GitHub)" <gi...@apache.org>.
DanielLeens commented on issue #10999:
URL: https://github.com/apache/seatunnel/issues/10999#issuecomment-4609603108

   Thanks for the clear write-up.
   
   I checked the current MongoDB source reader path in `dev`, and this does look like a real connector bug.
   
   The problematic path is that `MongodbReader.pollNext()` always runs `closeCurrentSplit()` in the `finally` block, but `closeCurrentSplit()` currently requires `cursor` to be non-null before closing it. So if `getCursor(...)` fails during cursor creation, the original MongoDB exception gets masked by a later `NullPointerException` from the cleanup path instead of surfacing to the user.
   
   So the direction in this issue is correct: the close path should be null-safe, and the original cursor-creation failure should remain visible in the logs.
   
   As a temporary workaround, you can still debug the underlying MongoDB connection / auth / query failure outside this masking path first, but the masking behavior itself should be fixed in the connector.
   
   We've labeled this as `bug` and `help wanted` — contributions are very welcome if you'd like to take it on.
   
   cc @chl-wxp


-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] MongoDB connector closeCurrentSplit() masks real errors with NullPointerException [seatunnel]

Posted by "chl-wxp (via GitHub)" <gi...@apache.org>.
chl-wxp commented on issue #10999:
URL: https://github.com/apache/seatunnel/issues/10999#issuecomment-4609647052

   Are you willing to submit a PR for this?


-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org