On Mon, 9 Sep 2024 19:30:35 GMT, Alexey Ivanov <[email protected]> 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