gnodet commented on code in PR #1902:
URL: https://github.com/apache/maven-resolver/pull/1902#discussion_r3419227319
##########
maven-resolver-api/src/main/java/org/eclipse/aether/transfer/TransferResource.java:
##########
@@ -46,9 +46,9 @@ public final class TransferResource {
private final RequestTrace trace;
- private long contentLength = -1L;
+ private volatile long contentLength = -1L;
Review Comment:
`TransferResource` is created by one thread but its `contentLength` and
`resumeOffset` are set later via setters and read from other threads (e.g.
transfer listeners). Without `volatile`, writes from the producing thread may
not be visible to listener threads due to the Java Memory Model — there is no
happens-before relationship between the set and get calls across threads.
##########
maven-resolver-connector-basic/src/main/java/org/eclipse/aether/connector/basic/BasicRepositoryConnectorFactory.java:
##########
@@ -57,7 +57,7 @@ public final class BasicRepositoryConnectorFactory implements
RepositoryConnecto
private final Map<String, ProvidedChecksumsSource>
providedChecksumsSources;
- private float priority;
+ private volatile float priority;
Review Comment:
`BasicRepositoryConnectorFactory` is a singleton component whose `priority`
can be set via `setPriority()` and read via `getPriority()` from different
threads. Without `volatile`, a priority change made by one thread may never be
seen by another thread reading it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]