RFR: 8328953 : JEditorPane.read throws ChangedCharSetException [v7]
Alexey Ivanov
aivanov at openjdk.org
Wed Mar 27 20:08:45 UTC 2024
On Wed, 27 Mar 2024 13:22:41 GMT, rjolly <duke at openjdk.org> wrote:
>> ChangedCharSetException is used to amend the charset during read according to html directives. Currently it causes immediate exit of the method which in turn causes failure to load html documents with charset directives (even if the latter must not change after all). This PR restores the catch operation as it was before the use of try with resources.
>
> rjolly has updated the pull request incrementally with one additional commit since the last revision:
>
> 8328953 : JEditorPane.read throws ChangedCharSetException
>
> The fix is to add a nested `try`-block inside `try-with-resource`; all the exceptions are handled in the nested `try`; the outer `try`-with-resouces only closes the input stream.
Other than the comment below, it looks fine.
Testing results are green. I'll run the tests once again after you update the code.
test/jdk/javax/swing/JEditorPane/EditorPaneCharset.java line 69:
> 67: Element p = body.getElement(0);
> 68: String pText = document.getText(p.getStartOffset(),
> 69: p.getEndOffset() - p.getStartOffset());
Suggestion:
String pText = document.getText(p.getStartOffset(),
p.getEndOffset() - p.getStartOffset() - 1);
The test fails for me without `-1` because `pText` contains `\n`. It didn't fail when I tested it earlier.
-------------
Changes requested by aivanov (Reviewer).
PR Review: https://git.openjdk.org/jdk/pull/17567#pullrequestreview-1964625088
PR Review Comment: https://git.openjdk.org/jdk/pull/17567#discussion_r1541947624
More information about the client-libs-dev
mailing list