Skip to content

[BUG] possible NPE in WorkerBulkByScrollTaskState.java #17839

@ngr-ilmarh

Description

@ngr-ilmarh

Describe the bug

Hello.

We've analyzed Opensearch sources with SAST and it pointed out possible NPE in https://github.com/opensearch-project/OpenSearch/blob/main/server/src/main/java/org/opensearch/index/reindex/WorkerBulkByScrollTaskState.java#L299

Code

            long remainingDelay = scheduled.getDelay(TimeUnit.NANOSECONDS);
            // Actually reschedule the task
            if (scheduled == null || false == scheduled.cancel()) {
                // Couldn't cancel, probably because the task has finished or been scheduled. Either way we have nothing to do here.
                logger.debug("[{}]: skipping rescheduling because we couldn't cancel the task", task.getId());
                return this;
            }

should throw NPE if sheduled is null.

Related component

No response

To Reproduce

Didn't catch it in action, just static analysis of the code

Expected behavior

No NPE if sheduled is null, need to swap blocks

Additional Details

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions