RFR: 8282548: Create a regression test for JDK-4330998 [v2]
Alexey Ivanov
aivanov at openjdk.java.net
Wed Mar 16 16:43:27 UTC 2022
On Wed, 16 Mar 2022 16:23:37 GMT, Alexey Ivanov <aivanov at openjdk.org> wrote:
>> Manukumar V S has updated the pull request incrementally with one additional commit since the last revision:
>>
>> Review comments fixed: Simplified the test, removed unwanted method
>
> test/jdk/javax/swing/JEditorPane/4330998/JEditorPaneSetTextNullTest.java line 41:
>
>> 39:
>> 40: try {
>> 41: SwingUtilities.invokeAndWait(() -> editorPane.setText(null));
>
> I believe the test could be simplified to
> Suggestion:
>
> SwingUtilities.invokeAndWait(() -> new JEditorPane().setText(null));
>
> And `createUI()` can be removed.
If you like to make sure the test expects `NullPointerException` only, you can use try-catch inside the lambda expression and propagate the exception thrown from `invokeAndWait`.
Yet it's not required: we don't expect any exceptions thrown. Therefore try-catch can be dropped too. If an exception is thrown, test fails. However, in this case a clarifying comment would be useful.
-------------
PR: https://git.openjdk.java.net/jdk/pull/7740
More information about the client-libs-dev
mailing list