java.security.NoSuchAlgorithmException should be a runtime exception

XMLWordPrintable

    • Type: Enhancement
    • Resolution: Won't Fix
    • Priority: P5
    • None
    • Affects Version/s: 7
    • Component/s: security-libs

      A DESCRIPTION OF THE REQUEST :
      When calling the method:
      java.security.MessageDigest#getInstance(java.lang.String algorithm)
      then java.security.NoSuchAlgorithmException if no Provider supports a MessageDigestSpi implementation for the specified.


      JUSTIFICATION :
      Following Java Tutorial, Lesson: Exceptions, section: Unchecked Exceptions — The Controversy:

      "One case where it is common practice to throw a RuntimeException is when the user calls a method incorrectly. For example, a method can check if one of its arguments is incorrectly null. If an argument is null, the method might throw a NullPointerException, which is an unchecked exception."

      I think when a developer try to get an algorithm that is not supported by the platform, that is developer mistake, not environment condition. He/she have to know which algorithm is supported before he/she decide to use it. So java.security.NoSuchAlgorithmException should be a runtime exception or MessageDigest#getInstance should throw runtime exception.


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      In most time, I just call MessageDigest.getInstance("MD5") on Sun JDK/Windows XP. I would not to catch NoSuchAlgorithmException because I'm sure that it never occurs. In some case I try to get an algorithm that is not supported by the platform, I would like to see a runtime exception so I can fix my bug.

            Assignee:
            Sean Mullan
            Reporter:
            Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: