sonatype-lift[bot] commented on code in PR #1126:
URL: https://github.com/apache/solr/pull/1126#discussion_r1103903226
##########
solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java:
##########
@@ -493,4 +434,94 @@ public interface CoreAdminOp {
*/
void execute(CallInfo it) throws Exception;
}
+
+ public static class CoreAdminAsyncTracker {
+ private static final int MAX_TRACKED_REQUESTS = 100;
+ public static final String RUNNING = "running";
+ public static final String COMPLETED = "completed";
+ public static final String FAILED = "failed";
+ public final Map<String, Map<String, TaskObject>> requestStatusMap;
+
+ private ExecutorService parallelExecutor =
+ ExecutorUtil.newMDCAwareFixedThreadPool(
+ 50, new
SolrNamedThreadFactory("parallelCoreAdminAPIBaseExecutor"));
+
+ public CoreAdminAsyncTracker() {
+ HashMap<String, Map<String, TaskObject>> map = new HashMap<>(3, 1.0f);
+ map.put(RUNNING, Collections.synchronizedMap(new LinkedHashMap<>()));
+ map.put(COMPLETED, Collections.synchronizedMap(new LinkedHashMap<>()));
+ map.put(FAILED, Collections.synchronizedMap(new LinkedHashMap<>()));
+ requestStatusMap = Collections.unmodifiableMap(map);
+ }
+
+ public void shutdown() {
+ ExecutorUtil.shutdownAndAwaitTermination(parallelExecutor);
+ }
+
+ public Map<String, TaskObject> getRequestStatusMap(String key) {
+ return requestStatusMap.get(key);
+ }
+
+ public ExecutorService getParallelExecutor() {
+ return parallelExecutor;
+ }
+
+ /** Helper method to add a task to a tracking type. */
+ public void addTask(String type, TaskObject o, boolean limit) {
+ synchronized (getRequestStatusMap(type)) {
+ if (limit && getRequestStatusMap(type).size() == MAX_TRACKED_REQUESTS)
{
+ String key =
getRequestStatusMap(type).entrySet().iterator().next().getKey();
+ getRequestStatusMap(type).remove(key);
+ }
+ addTask(type, o);
+ }
+ }
+
+ public void addTask(String type, TaskObject o) {
+ synchronized (getRequestStatusMap(type)) {
+ getRequestStatusMap(type).put(o.taskId, o);
+ }
+ }
+
+ /** Helper method to remove a task from a tracking map. */
+ public void removeTask(String map, String taskId) {
+ synchronized (getRequestStatusMap(map)) {
Review Comment:
<picture><img alt="5% of developers fix this issue"
src="https://lift.sonatype.com/api/commentimage/fixrate/5/display.svg"></picture>
<b>*NULLPTR_DEREFERENCE:</b>* `Map
CoreAdminHandler$CoreAdminAsyncTracker.getRequestStatusMap(String)` could be
null (from the call to
`CoreAdminHandler$CoreAdminAsyncTracker.getRequestStatusMap(...)` on line 488)
and is dereferenced.
ââ <b>2 similar findings have been found in this PR</b>
<details><summary>đ Expand here to view all instances of this
finding</summary><br/>
<div align=\"center\">
| **File Path** | **Line Number** |
| ------------- | ------------- |
| solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java |
[471](https://github.com/apache/solr/blob/3d8b1eb13ffc0307ec0a2d066e5e1bd40521e514/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java#L471)
|
| solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java |
[481](https://github.com/apache/solr/blob/3d8b1eb13ffc0307ec0a2d066e5e1bd40521e514/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java#L481)
|
<p><a
href="https://lift.sonatype.com/results/github.com/apache/solr/01GS3Z89WXDS3GKQY5ME5F0MAS?t=Infer|NULLPTR_DEREFERENCE"
target="_blank">Visit the Lift Web Console</a> to find more details in your
report.</p></div></details>
---
<details><summary>âšī¸ Expand to see all <b>@sonatype-lift</b>
commands</summary>
You can reply with the following commands. For example, reply with
***@sonatype-lift ignoreall*** to leave out all findings.
| **Command** | **Usage** |
| ------------- | ------------- |
| `@sonatype-lift ignore` | Leave out the above finding from this PR |
| `@sonatype-lift ignoreall` | Leave out all the existing findings from this
PR |
| `@sonatype-lift exclude <file\|issue\|path\|tool>` | Exclude specified
`file\|issue\|path\|tool` from Lift findings by updating your config.toml file |
**Note:** When talking to LiftBot, you need to **refresh** the page to see
its response.
<sub>[Click here](https://github.com/apps/sonatype-lift/installations/new)
to add LiftBot to another repo.</sub></details>
---
<b>Help us improve LIFT! (<i>Sonatype LiftBot external survey</i>)</b>
Was this a good recommendation for you? <sub><small>Answering this survey
will not impact your Lift settings.</small></sub>
[â[đ Not
relevant](https://www.sonatype.com/lift-comment-rating?comment=388185228&lift_comment_rating=1)
â] - [â[đ Won't
fix](https://www.sonatype.com/lift-comment-rating?comment=388185228&lift_comment_rating=2)
â] - [â[đ Not critical, will
fix](https://www.sonatype.com/lift-comment-rating?comment=388185228&lift_comment_rating=3)
â] - [â[đ Critical, will
fix](https://www.sonatype.com/lift-comment-rating?comment=388185228&lift_comment_rating=4)
â] - [â[đ Critical, fixing
now](https://www.sonatype.com/lift-comment-rating?comment=388185228&lift_comment_rating=5)
â]
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]