On Wed, 16 Mar 2022 16:36:22 GMT, Alexey Ivanov <[email protected]> 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