Skip to content

MLE-29324, MLE-29325: Fix silent NPE in getSslContext() and IndexOutOfBoundsException in ThreadManager Thread Scaling#603

Merged
vshaniga merged 1 commit into
marklogic:develop-11.3from
tposham:develop-11.3
May 7, 2026
Merged

MLE-29324, MLE-29325: Fix silent NPE in getSslContext() and IndexOutOfBoundsException in ThreadManager Thread Scaling#603
vshaniga merged 1 commit into
marklogic:develop-11.3from
tposham:develop-11.3

Conversation

@tposham
Copy link
Copy Markdown

@tposham tposham commented May 6, 2026

Backport from develop

Fix silent NPE in ContentReader.SslOptions.getSslContext()

When SSLContext.getInstance("TLSv1.3") throws NoSuchAlgorithmException, the catch block swallows the exception and execution continues with sslContext = null, causing an NPE on sslContext.init().

Fix:

  • Removed try-catch blocks that swallowed exceptions
  • Added throws NoSuchAlgorithmException, KeyManagementException to align with the SslConfigOptions interface contract
  • Exceptions now propagate to the caller which already handles them properly

Fix IndexOutOfBoundsException in ThreadManager thread scaling

LocalJobRunner.java:

  • Moved runThreadPoller() from before task submission to after, ensuring threads exist before the poller attempts to scale them

ThreadManager.java:

  • Added bounds checking with activeIdx in scaleOut() and scaleIn() to prevent IndexOutOfBoundsException when scaling beyond available thread pool size

Tests

  • Ran unit tests → All passed
  • Ran 06mlcp test suite → No regression failures were found

…fBoundsException in ThreadManager Thread Scaling
Copilot AI review requested due to automatic review settings May 6, 2026 14:10
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR backports fixes that prevent two runtime failures in mlcp: a silent null SSLContext leading to an NPE during SSL initialization, and an IndexOutOfBoundsException during auto-scaling thread allocation in ThreadManager.

Changes:

  • Propagate NoSuchAlgorithmException/KeyManagementException from SslOptions.getSslContext() instead of swallowing them and proceeding with a null SSLContext.
  • Prevent IndexOutOfBoundsException in thread scaling/idle-thread assignment by decoupling iteration over taskList from indexing into randomIndexes.
  • Start the thread poller after task submission in LocalJobRunner to avoid races between active-task snapshotting and scaling iteration.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/main/java/com/marklogic/mapreduce/examples/ContentReader.java Stops swallowing SSL initialization exceptions to prevent a follow-on NPE.
src/main/java/com/marklogic/contentpump/ThreadManager.java Adds bounds-safe indexing when distributing threads during scale-in/out and idle reassignment.
src/main/java/com/marklogic/contentpump/LocalJobRunner.java Defers starting the thread poller until after tasks are submitted to reduce scaling races.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/main/java/com/marklogic/mapreduce/examples/ContentReader.java
@abika5
Copy link
Copy Markdown
Contributor

abika5 commented May 6, 2026

Hi @tposham - This change impacts the thread manager and will need performance validations as well. Please let Andrea know that this change has been added, and we should monitor how this impacts the performance of mlcp.

And please use branching in the repository to make changes rather than forks.

Copy link
Copy Markdown
Contributor

@yunzvanessa yunzvanessa left a comment

Choose a reason for hiding this comment

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

The code change looks good. Thanks. Please make sure to stop using forks to generate PRs.

@vshaniga vshaniga merged commit 3931667 into marklogic:develop-11.3 May 7, 2026
6 of 7 checks passed
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.

6 participants