On 20/06/2018 04:32, Joe Wang wrote:
Thanks Alan. I created 8205058 to capture your suggestions. Please
see below for more details.
Changed the internal APIs to throw CCE instead. In the same way as the
previous changeset for 8201276, these methods are made specific for
the use cases (though they are now for Files.read/writeString only) so
that they are not mixed up with existing ones that may inadvertently
affect other usages.
One thing to note is that MalformedInputException or
UnmappableCharacterException will lose one piece of information in
comparison to the existing IAE, that is where it happens (offset).
Should there be an improvement in the future, we could consider add it
back to this part of code.
JBS: https://bugs.openjdk.java.net/browse/JDK-8205058
webrevs: http://cr.openjdk.java.net/~joehw/jdk11/8205058/webrev/
I see your point on MalformedInputException and
UnmappableCharacterException so maybe we can submit a new issue to track
the follow-on work.
The update means a lot of duplication in StringCoding. Did you consider
(or measure) having the private encode/decode methods take a parameter
to indicate the exception handling? Sherman might have suggestions on this.
In the tests, shouldn't testMalformedRead and testMalformedWrite be
updated so that expectedExceptions lists the specify exception that is
expected? If I read the update correctly then isn't checking for
MalformedInputException and UnmappableCharacterException anywhere (it
passes if IOException is thrown).
-Alan