RFR: 8339561: The test/jdk/java/awt/Paint/ListRepaint.java may fail after JDK-8327401 [v3]

Alexey Ivanov aivanov at openjdk.org
Mon Sep 16 11:41:10 UTC 2024


On Mon, 9 Sep 2024 19:30:35 GMT, Alexey Ivanov <aivanov at openjdk.org> wrote:

>> Sergey Bylokhov has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Update bug4490179.java
>
> test/jdk/java/awt/List/KeyEventsTest/KeyEventsTest.java line 53:
> 
>> 51: 
>> 52: public class KeyEventsTest {
>> 53:     private volatile TestState currentState;
> 
> I'd rather not declare it a `volatile`. It could give a false impression of being thread-safe but it is not. The `volatile` modifier has a meaning only when it's written and read subsequently. If the reference doesn't change, it has no effect on the visibility of the internal object state.
> 
> The value is assigned to `currentState` while holding a lock `LOCK`.
> 
> At the same time, `currentState.setAction(true)` is called without any synchronisation and adding `volatile` won't make the change of the state thread-safe.

Submitted [JDK-8340196](https://bugs.openjdk.org/browse/JDK-8340196): _j.a/List/KeyEventsTest/KeyEventsTest: TestState currentState is not thread-safe_.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/20861#discussion_r1760988001


More information about the client-libs-dev mailing list