Copilot commented on code in PR #2620:
URL:
https://github.com/apache/incubator-hugegraph/pull/2620#discussion_r2020135487
##########
hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/store/AbstractBackendStoreProvider.java:
##########
@@ -70,6 +72,30 @@ public void listen(EventListener listener) {
this.storeEventHub.listen(EventHub.ANY_EVENT, listener);
}
+ @Override
+ public void listenSchemaCacheClear(EventListener listener) {
+ if (!schemaCacheClearListened) {
+ synchronized (this) {
Review Comment:
Using an instance-level lock with static volatile flags may lead to race
conditions if multiple instances call listenSchemaCacheClear concurrently;
consider synchronizing on the class (e.g.,
synchronized(AbstractBackendStoreProvider.class)) to ensure global exclusivity.
```suggestion
synchronized (AbstractBackendStoreProvider.class) {
```
##########
hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/store/AbstractBackendStoreProvider.java:
##########
@@ -70,6 +72,30 @@ public void listen(EventListener listener) {
this.storeEventHub.listen(EventHub.ANY_EVENT, listener);
}
+ @Override
+ public void listenSchemaCacheClear(EventListener listener) {
+ if (!schemaCacheClearListened) {
+ synchronized (this) {
+ if (!schemaCacheClearListened) {
+ listen(listener);
+ schemaCacheClearListened = true;
+ }
+ }
+ }
+ }
+
+ @Override
+ public void listenDataCacheClear(EventListener listener) {
+ if (!vertexEdgeCacheClearListened) {
+ synchronized (this) {
Review Comment:
Using an instance-level lock with static volatile flags may lead to race
conditions in listenDataCacheClear; consider synchronizing on the class (e.g.,
synchronized(AbstractBackendStoreProvider.class)) to ensure that the flag
update is thread-safe across all instances.
```suggestion
synchronized (AbstractBackendStoreProvider.class) {
```
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]