MLE-28226, MLE-28260: Fix silent NPE in getSslContext() and IndexOutOfBoundsException in ThreadManager thread scaling#600
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes two runtime failure modes in MLCP’s SSL initialization and auto-scaling thread assignment logic to avoid silent failures and IndexOutOfBoundsExceptions during thread redistribution.
Changes:
ContentReader.SslOptions#getSslContext()now propagatesNoSuchAlgorithmException/KeyManagementExceptioninstead of swallowing them, preventing a silent NPE when SSL setup fails.ThreadManagernow uses anactiveIdxcounter when consumingrandomIndexesso completed tasks earlier intaskListdon’t causerandomIndexesto be indexed with the full loop index.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/main/java/com/marklogic/mapreduce/examples/ContentReader.java |
Removes exception-swallowing in SSLContext creation and aligns getSslContext() with the SslConfigOptions throws contract. |
src/main/java/com/marklogic/contentpump/ThreadManager.java |
Fixes incorrect indexing into randomIndexes by introducing activeIdx in scaling/idle-thread assignment paths. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
NeoSaber
left a comment
There was a problem hiding this comment.
The change for ContentReader looks fine to me.
I think copilot is correct that the change to ThreadManager doesn't quite fix the issue, but I don't really like its suggested fixes. They seem too much like overengineering to me.
My first thought was to try a modulo op to limit the activeIdx to the size of randomIndexes, but when I ran that suggestion by copilot it pointed out that wouldn't really work in the context of how the scaling functions are using it. It suggested adding something like this:
if (activeIdx >= randomIndexes.size()) {
if (LOG.isDebugEnabled()) {
LOG.debug("Skipping task added after active task snapshot; "
+ "it will be considered in the next polling cycle.");
}
continue;
}
I don't know what the best approach might be here. I am not a fan of any of the copilot suggestions I've seen for it, but my ideas might not work either.
…fBoundsException in ThreadManager Thread Scaling
|
Used copilot to generate fixes/suggestions, it says to move the LocalJobRunner.javaThreadManager.java |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
Fixes two bugs in MLCP error handling:
ContentReader.getSslContext()swallowedNoSuchAlgorithmException/KeyManagementException, causing a silent NPE when SSL initialization failed. Now propagates exceptions to the caller, which already handles them viaXccConfigException.ThreadManagermay crash withIndexOutOfBoundsExceptionwhen completed tasks appeared before active tasks intaskList. TherandomIndexeslist (sized to active task count) was accessed using the full loop index. Added a separateactiveIdxcounter that only increments for active tasks.Changes
Tests