Data race in field readOnlyBearerAuth
in class RegistryClient.java
#4374
Labels
readOnlyBearerAuth
in class RegistryClient.java
#4374
Environment:
Description of the issue:
There is a data race (according to the Java memory model) in the field
readOnlyBearerAuth
in classRegistryClient.java
. Due to this data race, it is possible that writes on the variable by one thread are not visible to other threads reading the variable in the future. This can happen, for instance, if two threads concurrent executedoPullBearerAuth()
anddoPushBearerAuth()
.Expected behavior:
Threads reading stale or outdated writes on the field
readOnlyBearerAuth
in classRegistryClient.java
Steps to reproduce:
Consider two threads
t1
andt2
and letreadOnlyBearerAuth==false
. Consider that t1 executesdoPullBearerAuth()
and concurrently t2 executesdoPushBearerAuth()
. The following execution can occur:readOnlyBearerAuth
as false in this linereadOnlyBearerAuth
as false (because there is no happens-before relation between the write by t1 and this read and the java memory model does not ensure that the write by t1 is visible to t2)Additional Information:
The problem can be solved by defining
readOnlyBearerAuth
asvolatile
.The text was updated successfully, but these errors were encountered: