On Thu, 24 Sep 2026 10:23:41 GMT, Christopher Schnick <[email protected]> 
wrote:

>> modules/javafx.controls/src/test/java/test/javafx/scene/control/ContextMenuTest.java
>>  line 374:
>> 
>>> 372: 
>>> 373:         // Fail on internal exceptions
>>> 374:         ControlTestUtils.runWithExceptionHandler(() -> subMenu.show());
>> 
>> You could also use: `assertDoesNotThrow(() -> subMenu.show());`
>> 
>> but that will require the following setup already used in other tests:
>> 
>> 
>>     @BeforeEach
>>     public void setup() {
>>         Thread.currentThread().setUncaughtExceptionHandler((thread, 
>> throwable) -> {
>>             if (throwable instanceof RuntimeException) {
>>                 throw (RuntimeException)throwable;
>>             } else {
>>                 
>> Thread.currentThread().getThreadGroup().uncaughtException(thread, throwable);
>>             }
>>         });
>>     }
>> 
>>     @AfterEach
>>     public void cleanup() {
>>         Thread.currentThread().setUncaughtExceptionHandler(null);
>>     }
>> 
>> 
>> Personally I like that more, because `assertDoesNotThrow` shows the 
>> intention very clearly.
>
> What is the issue with ControlTestUtils.runWithExceptionHandler, just the 
> naming? I thought that existed exactly to remove the need for that setup code

Ok, how does it look now?

-------------

PR Review Comment: https://git.openjdk.org/jfx/pull/2321#discussion_r4092583926

Reply via email to