MLE-29324, MLE-29325: Fix silent NPE in getSslContext() and IndexOutOfBoundsException in ThreadManager Thread Scaling#603
Conversation
…fBoundsException in ThreadManager Thread Scaling
There was a problem hiding this comment.
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/KeyManagementExceptionfromSslOptions.getSslContext()instead of swallowing them and proceeding with a nullSSLContext. - Prevent
IndexOutOfBoundsExceptionin thread scaling/idle-thread assignment by decoupling iteration overtaskListfrom indexing intorandomIndexes. - Start the thread poller after task submission in
LocalJobRunnerto 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.
|
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. |
Backport from develop
Fix silent NPE in
ContentReader.SslOptions.getSslContext()When
SSLContext.getInstance("TLSv1.3")throwsNoSuchAlgorithmException, the catch block swallows the exception and execution continues withsslContext = null, causing an NPE onsslContext.init().Fix:
throws NoSuchAlgorithmException, KeyManagementExceptionto align with theSslConfigOptionsinterface contractFix IndexOutOfBoundsException in ThreadManager thread scaling
LocalJobRunner.java:
runThreadPoller()from before task submission to after, ensuring threads exist before the poller attempts to scale themThreadManager.java:
activeIdxinscaleOut()andscaleIn()to preventIndexOutOfBoundsExceptionwhen scaling beyond available thread pool sizeTests