enkilee opened a new pull request, #5067:
URL: https://github.com/apache/rocketmq-dashboard/pull/5067

   ## Summary
   - Fix a `NullPointerException` risk in `CollectorScheduler.awaitJob` where
     `ExecutionException.getCause()` was dereferenced without a null check.
     Although `FutureTask` normally sets a non-null cause, the 
`ExecutionException`
     API contract permits a null cause (e.g. `new ExecutionException(null)` is
     legal). When cause was null, `error.getCause().getMessage()` threw an NPE
     that escaped the `@Scheduled` collection pass, aborting the current metric
     collection cycle and polluting monitoring with NPE stack traces that lacked
     the original failure context.
   ## Changes
   - `CollectorScheduler.awaitJob`: extract `cause = error.getCause()` and fall
     back to `error.getMessage()` when cause is null, logging a meaningful
     message in both cases.
   - Add two regression tests in `CollectorSchedulerTest`:
     - `awaitJobDoesNotThrowNpeWhenExecutionExceptionCauseIsNullTest`: verifies
       no NPE is thrown when `ExecutionException` carries a null cause.
     - `awaitJobLogsCauseMessageWhenExecutionExceptionHasCauseTest`: verifies
       the cause's message is logged when cause is present.
   ## Root Cause
   `ExecutionException.getCause()` does not guarantee a non-null return. The
   previous code unconditionally called `error.getCause().getMessage()`, which
   threw NPE for a null cause. The NPE was a `RuntimeException` and was not
   caught by the surrounding `catch (InterruptedException)` /
   `catch (RejectedExecutionException)` handlers, so it propagated up to the
   Spring `@Scheduled` invoker and aborted the collection pass.
   ## Verification
   - `mvn test -Dtest=CollectorSchedulerTest` → 14 tests, 0 failures, 0 errors.
   - Existing tests continue to pass; new tests cover both the null-cause and
     non-null-cause branches of the fix.


-- 
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]

Reply via email to