On Mon, 14 Oct 2024 15:16:01 GMT, Abhishek Kumar <abhis...@openjdk.org> wrote:
>> Why? >> >> This comment is meant for the `modelArmed` flag. The way it's used now is >> thread-safe because of using `mouseEntered`, specifically a value is written >> to the flag before `mouseEntered.countDown()` is called, and its value is >> read after `mouseEntered.await` returns. >> >> If any of the above is modified, the `modelArmed` flag may become not >> thread-safe and require some kind of synchronisation. > > Ok.. I misunderstood `mouseEntered` flag, thought the comment is for > `CountDownLatch` object. I expanded the comment, I hope it's clearer now. >> Yes, it's an option. >> >> I used the same approach in #21474 where the test object serves as an event >> handler. This avoids anonymous classes which add indentation. > > Yeah, this is an option. As I mentioned earlier that MouseMotionListener is > not needed, so creating an eventHandler object may not be of great use. I > agree if more than one listener needs to be added, creating an eventHandler > object is a good idea. I removed the unneeded listener and inlined creation of the event handler. Thus, I kept the current structure of test code. I prefer it this way for consistency with `JButton/bug4490179.java` in https://github.com/openjdk/jdk/pull/21474. Both tests are really similar, and I think consistent coding helps. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/21475#discussion_r1799732359 PR Review Comment: https://git.openjdk.org/jdk/pull/21475#discussion_r1799731378