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

CharacterEncoder throws Errors and loses causing exceptions

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: P4 P4
    • None
    • 6u21
    • core-libs

      A DESCRIPTION OF THE REQUEST :
      sun.misc.CharacterEncoder.encode(byte[]) and encodeBuffer(byte[]) throw a java.lang.Error, but ignore the causing exception so its stacktrace is being lost and makes it more difficult to find the real problem.

      It is also catching ALL Exception types and rethrows them as an Error, which is not a recommended practice for RuntimeException types.

      JUSTIFICATION :
      It otherwise makes determining of the root cause of problems nearly impossible. I just filed an other bug report, which shows that a static sun.misc.HexDumpEncoder instance used in sun.security.krb5.EncryptionKey.toString() caused ArrayIndexOutOfBoundsException in the encodeAtom method. However this exception was lost as the CharacterEncoder.encode method replaces it by the "internal Error" message.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Either the causing exception should be added in the Error constructor or do not catch all exception types and rethrow them as an Error at all.
      ACTUAL -
      Causing exception is lost and all exception types are catched and rethrown as Errors.

            sherman Xueming Shen
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Imported:
              Indexed: