yuqi1129 opened a new pull request, #12514: URL: https://github.com/apache/gravitino/pull/12514
### What changes were proposed in this pull request? 1. `testCatalogCacheRemoveListener` now runs against its own `CatalogManager` and `InMemoryEntityStore` instead of the `static` instance shared by the whole test class. 2. `reset()` (`@BeforeEach`/`@AfterEach`) additionally invalidates the shared catalog cache, so cache entries no longer leak from one test method to the next. 3. `CatalogManager.removalListeners` becomes a `CopyOnWriteArrayList`. ### Why are the changes needed? The shared `CatalogManager` is created once in `@BeforeAll` and `reset()` only cleared `entityStore`, so its catalog cache accumulated entries across test methods. Instrumenting the test showed 4 leftover entries present when it starts: ``` cache size at test start = 4 keys=[metalake.test1, metalake.catalog_rel, metalake.catalog_file, metalake.test51] ``` Caffeine delivers removal notifications asynchronously, and `CatalogManager` has no API to unregister a listener, so those leftover removals could reach the listener this test registers, producing the reported `expected: <1> but was: <5>` (4 leftovers + its own). `removalListeners` was a plain `ArrayList` iterated on cache executor threads while `addCatalogCacheRemoveListener` may append concurrently — unsafe regardless of the flaky test. Fix: #12504 ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? - `./gradlew :core:test --tests "org.apache.gravitino.catalog.TestCatalogManager" -PskipITs` passes. - Temporarily annotated the class with `@TestMethodOrder(MethodOrderer.Random.class)` and re-ran it 3 times with `--rerun-tasks`; all green (annotation not included in the commit). -- 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]
