-
Notifications
You must be signed in to change notification settings - Fork 31
MLE-26838: Added null check for conf.getStrings() method in various files #563
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
Co-authored-by: Abika Santhosh Kumar <asanthos@rh8-asanthos-03.bedford.progress.com>
MLE-25326: version update
…-xcc MLE-25329: update xcc jar
MLE-25326: Release 12.0.1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Adds defensive checks around Configuration#getStrings(...) results to avoid null pointer dereferences during host resolution/config parsing across MapReduce + Content Pump components.
Changes:
- Add null/empty-array validation for
INPUT_HOST/OUTPUT_HOSTbefore indexing[0]. - Fail fast with
IllegalArgumentExceptionwhen required host lists are missing. - Apply the pattern across utilities, readers, formats, and thread management.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
src/main/java/com/marklogic/mapreduce/utilities/InternalUtilities.java |
Guards getStrings(INPUT_HOST) before indexing to avoid NPE. |
src/main/java/com/marklogic/mapreduce/ContentOutputFormat.java |
Validates OUTPUT_HOST when restrictHosts is enabled. |
src/main/java/com/marklogic/contentpump/utilities/PermissionUtil.java |
Validates OUTPUT_HOST before selecting first host for session creation. |
src/main/java/com/marklogic/contentpump/TransformOutputFormat.java |
Validates OUTPUT_HOST before attempting to query MIME types. |
src/main/java/com/marklogic/contentpump/ThreadManager.java |
Validates OUTPUT_HOST list before iterating for host checks. |
src/main/java/com/marklogic/contentpump/RDFReader.java |
Validates OUTPUT_HOST before selecting first host for permissions initialization. |
src/main/java/com/marklogic/contentpump/InputType.java |
Validates OUTPUT_HOST before iterating through hosts for connection attempts. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| " is not specified."); | ||
| } | ||
| String host = hosts[0]; | ||
|
|
Copilot
AI
Feb 9, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change prevents NPE on a null/empty array, but it also removes the previous validation that hosts[0] itself is non-null/non-empty. As a result, a config like INPUT_HOST= (or an array containing null) will pass the new guard and can still fail later (or attempt to connect with an invalid hostname). Consider restoring a value-level check (e.g., null/blank after trimming) for hosts[0], or switch to a trimmed-string API and validate the first entry.
| if (host == null || host.trim().isEmpty()) { | |
| throw new IllegalArgumentException(INPUT_HOST + | |
| " is not specified."); | |
| } |
| } | ||
| for (String host : hosts) { |
Copilot
AI
Feb 9, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new guard ensures the array exists, but individual entries may still be blank/whitespace (or null), which can cause connection attempts with invalid hostnames inside the loop. Add validation inside the loop (or pre-filter/normalize the array) to reject/skip empty hosts deterministically.
| } | |
| for (String host : hosts) { | |
| } | |
| List<String> validHosts = new ArrayList<String>(); | |
| for (String host : hosts) { | |
| if (host != null && !host.trim().isEmpty()) { | |
| validHosts.add(host); | |
| } | |
| } | |
| if (validHosts.isEmpty()) { | |
| throw new IllegalArgumentException(MarkLogicConstants.OUTPUT_HOST + | |
| " does not contain any valid non-empty host values."); | |
| } | |
| for (String host : validHosts) { |
| String[] hosts = conf.getStrings(MarkLogicConstants.OUTPUT_HOST); | ||
| if (hosts == null || hosts.length == 0) { | ||
| throw new IllegalArgumentException(MarkLogicConstants.OUTPUT_HOST + | ||
| " is not specified."); | ||
| } | ||
| cs = InternalUtilities.getOutputContentSource(conf, | ||
| conf.getStrings(MarkLogicConstants.OUTPUT_HOST)[0]); | ||
| hosts[0]); |
Copilot
AI
Feb 9, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same getStrings(...) null/length check + identical exception message is now repeated across several files in this PR. To reduce duplication and keep host-validation semantics consistent (including trimming/blank checks), consider extracting a shared helper (e.g., in InternalUtilities) that returns a validated host list (or first host) and throws a consistent error when missing/invalid.
As part of Polaris Null Pointer Dereference issues cleanup, I have added null checks for the conf.getStrings() method in the following files: