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

Improve error message for NumberFormatException on null input

XMLWordPrintable

    • b11
    • generic
    • generic
    • Verified

      A DESCRIPTION OF THE PROBLEM :
      Long.valueOf(null);

      Exception in thread "main" java.lang.NumberFormatException: null
          at java.base/java.lang.Long.parseLong(Long.java:655)
          at java.base/java.lang.Long.valueOf(Long.java:1144)
          at Main.main(Main.java:3)

      This error message is a bit hard to decipher without understand that the Exception message IS the value passed in (null). It just looks like there is no message with this Exception. It would be better (and seems to be the current trend) if this method was more cleat in the JavaDocs about 'null' and also that it threw an explicit NPE (Objects#requireNonNull).


            darcy Joe Darcy
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: