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

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 11
    • Fix Version/s: 11
    • Component/s: core-libs
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      b20
    • Verification:
      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

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

                  Dates

                  • Created:
                    Updated:
                    Resolved: