On Tue, 21 Jun 2022 21:49:58 GMT, Naoto Sato <[email protected]> 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`. > > Naoto Sato has updated the pull request incrementally with one additional > commit since the last revision: > > Moved `@Test` annotations Marked as reviewed by alanb (Reviewer). test/jdk/java/nio/file/Files/ReadWriteString.java line 304: > 302: throws IOException { > 303: Path path = Files.createTempFile("illegalInputBytes", null); > 304: path.toFile().deleteOnExit(); Although this is consistent with the existing tests in this source file, I think it would be better if we change it to create the temporary files in the current directory and not delete it. Leaving the file behind is useful for diagnosing issues where there re test failures. We can do that in a separate issue if you'd like. ------------- PR: https://git.openjdk.org/jdk/pull/9193
