RFR: 8333403: Write a test to check various components events are triggered properly [v5]

Ravi Gupta rgupta at openjdk.org
Fri Jul 12 08:43:52 UTC 2024


On Fri, 5 Jul 2024 20:12:09 GMT, Alexey Ivanov <aivanov at openjdk.org> wrote:

>> Ravi Gupta has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   8333403: Review comments fixed
>
> test/jdk/java/awt/event/ComponentEvent/ComponentEventTest.java line 56:
> 
>> 54: 
>> 55:     private static Frame frame;
>> 56:     private static int DELAY = 500;
> 
> Suggestion:
> 
>     private static final int DELAY = 500;
> 
> It's a constant, isn't it?

yes its constant.

> test/jdk/java/awt/event/ComponentEvent/ComponentEventTest.java line 66:
> 
>> 64:     private volatile static Dimension compSize;
>> 65:     private volatile static ArrayList<ComponentEvent> events =
>> 66:         new ArrayList<>();
> 
> Marking a list as `volatile` is not enough to access the contents of the list from different threads, you have to use a synchronized collection and iterate over `events` while holding the lock.

modified as below 

    private volatile static java.util.List<ComponentEvent> events =
        Collections.synchronizedList(new ArrayList<ComponentEvent>());

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

PR Review Comment: https://git.openjdk.org/jdk/pull/19521#discussion_r1675520625
PR Review Comment: https://git.openjdk.org/jdk/pull/19521#discussion_r1675519953


More information about the client-libs-dev mailing list