imbajin commented on code in PR #3058:
URL: https://github.com/apache/hugegraph/pull/3058#discussion_r3388595810


##########
hugegraph-server/hugegraph-test/src/main/java/org/apache/hugegraph/unit/cache/CachedGraphTransactionTest.java:
##########
@@ -265,18 +255,58 @@ public void 
testClosingNonOwnerKeepsGraphCacheListenerRegistered()
         Assert.assertSame(holder, cacheListeners.get(graphName));
         Assert.assertEquals(refCount + 1, holderRefCount(holder));
 
-        try {
-            second.close();
+        second.close();
 
-            Assert.assertSame(holder, cacheListeners.get(graphName));
-            Assert.assertEquals(refCount, holderRefCount(holder));
-            Assert.assertTrue(this.params.graphEventHub()
-                                         .listeners(Events.CACHE)
-                                         .contains(registered));
-        } finally {
-            restoreStoreListenerStatusForKnownTeardownBug(storeListeners,
-                                                           graphName);
-        }
+        Assert.assertSame(holder, cacheListeners.get(graphName));
+        Assert.assertEquals(refCount, holderRefCount(holder));
+        Assert.assertTrue(this.params.graphEventHub()
+                                     .listeners(Events.CACHE)
+                                     .contains(registered));
+    }
+
+    @Test
+    public void testClosingNonOwnerKeepsStoreListenerRegistered()
+            throws Exception {
+        ConcurrentMap<String, Object> storeListeners = storeEventListeners();
+
+        String graphName = this.params.spaceGraphName();
+        Object holder = storeListeners.get(graphName);
+        Assert.assertNotNull(holder);
+        EventListener registered = holderListener(holder);
+        int refCount = holderRefCount(holder);
+
+        CachedGraphTransaction second = new CachedGraphTransaction(
+                this.params, this.params.loadGraphStore());
+        Assert.assertSame(holder, storeListeners.get(graphName));
+        Assert.assertEquals(refCount + 1, holderRefCount(holder));
+
+        second.close();
+
+        // Non-owner close must decrement the refcount, not drop the entry
+        Assert.assertSame(holder, storeListeners.get(graphName));
+        Assert.assertEquals(refCount, holderRefCount(holder));
+        Assert.assertSame(registered, holderListener(holder));
+    }
+
+    @Test
+    public void testLastCloseRemovesStoreListener() throws Exception {

Review Comment:
   ⚠️ **Cover the owner-first store listener path**
   
   The new store-listener tests cover the non-owner close and final-release 
cases, but they do not exercise the owner-first path that this ref-counted 
lifecycle is meant to protect. Please add a store-side equivalent of 
`testCacheListenerSurvivesOwnerClose()`: close the owner transaction first, 
trigger a store event such as `STORE_CLEAR` / `STORE_TRUNCATE`, and verify the 
surviving transaction still observes it through the provider listener. That 
would also give the provider-replacement branch in `CachedGraphTransaction` a 
useful regression guard if the test can reopen the same graph name with a new 
provider.



-- 
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]

Reply via email to