RFR: 8361067: Test ExtraButtonDrag.java requires frame.dispose in finally block [v9]

Damon Nguyen dnguyen at openjdk.org
Wed Aug 13 22:14:18 UTC 2025


On Wed, 6 Aug 2025 09:43:48 GMT, Ravi Gupta <rgupta at openjdk.org> wrote:

>> Test test/jdk/java/awt/Mouse/MouseModifiersUnitTest/ExtraButtonDrag.java left debris on system whenever fails its required frame.dispose() in finally block.
>> 
>> 
>>  finally {
>>             EventQueue.invokeAndWait(ExtraButtonDrag::disposeFrame);
>>         }
>>     public static void disposeFrame() {
>>         if (frame != null) {
>>             frame.dispose();
>>             frame = null;
>>         }
>>     }
>
> Ravi Gupta has updated the pull request incrementally with one additional commit since the last revision:
> 
>   8361067: Added review comment

Tested on macOS and Ubuntu 24.04 (Wayland & X). Test passes on all except I get a timeout error on Wayland. Can you confirm that this test passes on your end on Wayland?

test/jdk/java/awt/Mouse/MouseModifiersUnitTest/ExtraButtonDrag.java line 114:

> 112:             // move. By default we send MOVED event.
> 113:             // XToolkit: extra buttons should report MOVED events only
> 114:             // WToolkit: extra buttons should report DRAGGED events only

One suggestion could be to use `Toolkit.getDefaultToolkit().getClass().getName()` to access the toolkit names. Some other tests in the test directory use this already. However, as Phil mentioned, I suppose this current way is fine.

test/jdk/java/awt/Mouse/MouseModifiersUnitTest/ExtraButtonDrag.java line 186:

> 184:         if (frame != null) {
> 185:             frame.dispose();
> 186:             frame = null;

Usually `frame.dispose()` is enough but having `frame = null` is fine too I suppose.

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

PR Review: https://git.openjdk.org/jdk/pull/26043#pullrequestreview-3117841941
PR Review Comment: https://git.openjdk.org/jdk/pull/26043#discussion_r2274741488
PR Review Comment: https://git.openjdk.org/jdk/pull/26043#discussion_r2274737204


More information about the client-libs-dev mailing list