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

(fs) Files read/writeString should throw CharacterCodingException instead of IOException with an IllegalArgumentException as cause

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P3
    • 11
    • 11
    • core-libs
    • b20
    • Verified

    Backports

      Description

        Files read/writeString implementation could be cleaner if it throws CharacterCodingException instead of an IOException with an IllegalArgumentException as cause for the malformed or unmappable cases.

        The code can be cleaner with an import of jdk.internal.misc.JavaLangAccess rather than repeating the fully qualified class name. The definition of JLA can be moved up to the top. There's also a few inconsistencies with the existing code that would be good to fix (indenting and line length issues mostly).

        The test looks reasonable. In getData() then then "shouldn't happen" case should throw an exception as a NPE here might be tricky to diagnose there. Another nit is the sb field - can that be removed.

        Attachments

          Issue Links

            Activity

              People

                joehw Joe Wang
                joehw Joe Wang
                Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved: