MLE-32054: [java-client-api][polaris]Improper Resource Shutdown or Release - #1970
Merged
Conversation
ngodugu-marklogic
requested review from
RitaChen609,
jonmille,
rjdew-progress and
rjrudin
as code owners
August 20, 2026 14:56
There was a problem hiding this comment.
Pull request overview
Fixes a CWE-404 resource leak in the examples module’s Optic Data Movement listeners by ensuring the RowSet<RowRecord> returned from RowManager.resultRows(...) is always closed (it holds an open HTTP response stream).
Changes:
- Wraps
rowManager.resultRows(exportPlan)in try-with-resources inOpticExportListener.processEventto reliably close theRowSet. - Applies the same try-with-resources pattern in
OpticExportToWriterListener.processEvent(inside the existingsynchronized (writer)block). - Adds the necessary
RowSetimports.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| examples/src/main/java/com/marklogic/client/example/cookbook/datamovement/OpticExportListener.java | Ensures RowSet is closed via try-with-resources during row iteration to prevent connection/resource leaks. |
| examples/src/main/java/com/marklogic/client/example/cookbook/datamovement/OpticExportToWriterListener.java | Ensures RowSet is closed via try-with-resources while exporting rows to a Writer, preventing per-batch connection/resource leaks. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
ngodugu-marklogic
force-pushed
the
MLE-32054
branch
from
August 20, 2026 14:58
d60e1eb to
4af868a
Compare
jonmille
approved these changes
Aug 20, 2026
rjdew-progress
approved these changes
Aug 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Description
Fix CWE-404 resource leak in OpticExportListener and OpticExportToWriterListener
Problem
RowSet implements Closeable (it holds an open HTTP response stream from MarkLogic). Both OpticExportListener.processEvent() and OpticExportToWriterListener.processEvent() iterated over rowManager.resultRows(exportPlan) using a plain for-each loop, which never closes the RowSet. This leaks the underlying connection on every batch processed, reducing future resource availability (Polaris CWE-404, Risk Score 80).
Fix
Wrapped rowManager.resultRows() in a try-with-resources block in both classes, ensuring the RowSet is closed on all exit paths including exceptions. This matches the pattern already established in RowTemplate.java.
Files Changed
Validation