On Thu, 16 Jun 2022 22:21:23 GMT, Naoto Sato <na...@openjdk.org> wrote:
> This is a regression caused by the fix to > [JDK-8286287](https://bugs.openjdk.org/browse/JDK-8286287), which assumed the > method `String.decodeWithDecoder()` was only invoked with cs.REPLACE mode > based on the comment "should not happen". Possibly this refers to the > `String(byte[], int, int, Charset)` constructor, which specifically mentions > the `REPLACE` mode. However, the method is invoked with > `String.newStringNoRepl()` and it should NOT replace the malformed input > (duh!). The fix is to throw an `Error` for the former case as before the > regression, and `CharacterCodingException` for the latter via an > `IllegalArgumentException`. > In fact, `Files.readString()` stopped throwing a `MalformedInputException` > since JDK17 with the fix to JDK-8259842, which started throwing an `Error`. This pull request has now been integrated. Changeset: 2728770e Author: Naoto Sato <na...@openjdk.org> URL: https://git.openjdk.org/jdk/commit/2728770e3d73bb11c4d6e54b5aff91588a1a780b Stats: 231 lines in 4 files changed: 143 ins; 68 del; 20 mod 8288589: Files.readString ignores encoding errors for UTF-16 Reviewed-by: rriggs, iris, alanb ------------- PR: https://git.openjdk.org/jdk/pull/9193