Skip to content

Fixed Polaris reported CWE-404 - #1987

Open
hmadala001 wants to merge 1 commit into
developfrom
MLE-29977-resource-shutdown
Open

hmadala001 wants to merge 1 commit into
developfrom
MLE-29977-resource-shutdown

Conversation

@hmadala001

Copy link
Copy Markdown

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Regression tests are missing for both changed InputStream overloads to verify underlying input cleanup when unconsumed or partially consumed streams are closed and UncheckedIOException when InputStream.close() fails.

1 open issue
What changed in this PR

This PR addresses Polaris-reported CWE-404 resource cleanup issues in the Java client library and its Jackson example.

Changes:

  • Use try-with-resources for JSON generators and the example input stream.
  • Close internally created JSON parsers when splitter streams are closed or stream setup fails.
File Description
marklogic-client-api/​src/​main/​java/​com/​marklogic/​client/​pojo/​util/​GenerateIndexConfig.java Ensure the configuration generator closes on failure.
marklogic-client-api/​src/​main/​java/​com/​marklogic/​client/​io/​JacksonParserHandle.java Ensure generators close in both write implementations.
marklogic-client-api/​src/​main/​java/​com/​marklogic/​client/​datamovement/​JSONSplitter.java Add parser cleanup handlers and setup-failure cleanup.
examples/​src/​main/​java/​com/​marklogic/​client/​example/​handle/​JacksonHandleExample.java Scope the example input stream with try-with-resources.

Review effort: Balanced

JsonParser jsonParser = new JsonFactory().createParser(input);
return split(jsonParser);
try {
return split(jsonParser).onClose(() -> closeParser(jsonParser));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants