A root cause is the underlying reason a software behavior or failure occurs. The visible exception location may only be a consequence, so investigate what happened earlier before changing that line. section 4.1.1
Use root-cause investigation to:
- Start with logs and exception stack traces, then continue with a debugger, profiler, or other suitable technique. section 4.1.1
- Ask why the failing reference, value, or behavior occurred instead of immediately adding local conditionals or exception handlers. section 4.1.1
- Reproduce the failure when possible, both to investigate it and to verify the eventual solution. section 1.5
A misleading NullPointerException
A log reports a NullPointerException inside a worker thread. The exception identifies where execution failed, but the missing reference may result from an earlier instruction that behaved unexpectedly. Investigate that earlier behavior rather than hiding the symptom with a try-catch or if-else. section 4.1.1
java.lang.NullPointerException at java.base/java.util.concurrent.ThreadPoolExecutor ➥runWorker(ThreadPoolExecutor.java:1128) ~[na:na] at java.base/java.util.concurrent.ThreadPoolExecutor$Worker ➥run(ThreadPoolExecutor.java:628) ~[na:na] at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable ➥run(TaskThread.java:61) ~[tomcat-embed-core-9.0.26.jar:9.0.26] at java.base/java.lang.Thread.run(Thread.java:830) ~[na:na]
Use the stack trace to locate the failing execution path and identify which methods called it. section 4.3




