Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8280174

Possible NPE in Thread.dispatchUncaughtException

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 19
    • 17, 18, 19
    • core-libs
    • b07

      Thread.dispatchUncaughtException calls getUncaughtExceptionHandler() which reads volatile field twice:

          private volatile UncaughtExceptionHandler uncaughtExceptionHandler;

          public UncaughtExceptionHandler getUncaughtExceptionHandler() {
              return uncaughtExceptionHandler != null ?
                  uncaughtExceptionHandler : group;
          }

          private void dispatchUncaughtException(Throwable e) {
              getUncaughtExceptionHandler().uncaughtException(this, e);
          }

      Another thread could change uncaughtExceptionHandler between 2 volatile reads. It will result in NullPointerException

            aturbanov Andrey Turbanov
            aturbanov Andrey Turbanov
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: