LuciferYang opened a new issue, #13165:
URL: https://github.com/apache/gravitino/issues/13165

   ### Version
   
   main branch
   
   ### Describe what's wrong
   
   `GravitinoCatalogManager.close()` closes every cached client on the calling 
thread and then calls `clients.invalidateAll()`. The removal listener on that 
cache also closes the client, and Caffeine dispatches removal listeners on 
`ForkJoinPool.commonPool()`, so each client gets a second `close()` on a pool 
thread some time after `close()` has already returned.
   
   For a real client that second close does nothing: 
`GravitinoClientBase#close` swallows whatever the underlying REST client 
throws. It does break a test. `TestBaseCatalogSecrets` shares one mocked 
`GravitinoClient` across its three cases and re-stubs it in `setUpCatalog`, 
which also closes the manager. If the pool thread's `close()` lands between 
`gravitinoClient.loadCatalog(any())` and `thenReturn`, Mockito resolves the 
pending stubbing to `close` and the case fails.
   
   Both the test and the manager live in `spark-connector/spark-common`, so any 
Spark line can hit it.
   
   ### Error message and/or stacktrace
   
   ```
   org.mockito.exceptions.misusing.CannotStubVoidMethodWithReturnValue:
   'close' is a *void method* and it *cannot* be stubbed with a *return value*!
        at TestBaseCatalogSecrets.setUpCatalog(TestBaseCatalogSecrets.java:123)
        at 
TestBaseCatalogSecrets.testMergeSecretsNullProps(TestBaseCatalogSecrets.java:82)
   ```
   
   ### How to reproduce
   
   main branch. The double close itself is deterministic: drain 
`ForkJoinPool.commonPool()` after `GravitinoCatalogManager#close` and every 
cached client reports two `close()` calls. The `TestBaseCatalogSecrets` failure 
depends on when the pool thread runs, and turns up occasionally in the Spark 
unit suite.
   
   ### Additional context
   
   `TestGravitinoCatalogManager.ClientFactory` records only whether a client 
was closed at least once, with a comment noting that the shutdown path and the 
removal listener may both fire, so the second close never fails an assertion 
today.
   


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

Reply via email to