Copilot commented on code in PR #13577:
URL: https://github.com/apache/skywalking/pull/13577#discussion_r2520672840
##########
oap-server/server-cluster-plugin/cluster-kubernetes-plugin/src/main/java/org/apache/skywalking/oap/server/cluster/plugin/kubernetes/KubernetesLabelSelectorEndpointGroup.java:
##########
@@ -48,6 +50,8 @@ public class KubernetesLabelSelectorEndpointGroup extends
DynamicEndpointGroup {
private final String portName;
private final SharedIndexInformer<Pod> podInformer;
private final String selfUid;
+ @Getter
+ private Endpoint selfEndpoint;
Review Comment:
The `selfEndpoint` field is accessed and modified by multiple threads
without synchronization. The `updateEndpoints()` method is called from the
`PodEventHandler` which processes Kubernetes events from multiple threads.
Without proper synchronization (e.g., using `volatile` or `synchronized`), this
could lead to visibility issues where `KubernetesCoordinator` reads a stale or
partially constructed value.
Consider making the field `volatile`:
```java
@Getter
private volatile Endpoint selfEndpoint;
```
```suggestion
private volatile Endpoint selfEndpoint;
```
--
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]