RFR: 8282548: Create a regression test for JDK-4330998 [v2]
Manukumar V S
mvs at openjdk.java.net
Wed Mar 16 16:43:28 UTC 2022
On Wed, 16 Mar 2022 16:36:22 GMT, Alexey Ivanov <aivanov at openjdk.org> wrote:
>> 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.
But if we want to throw the RuntimeException with a failure message, I think we need to catch it, right?
-------------
PR: https://git.openjdk.java.net/jdk/pull/7740
More information about the client-libs-dev
mailing list