This is an automated email from the ASF dual-hosted git repository.

yuqi4733 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/gravitino.git


The following commit(s) were added to refs/heads/main by this push:
     new 397cd4d912 [#8668] improvement(core): prevent handing out new clients 
after pool closure (#8682)
397cd4d912 is described below

commit 397cd4d912e8260062910624eabd9db3ab40eb8b
Author: keepConcentration <[email protected]>
AuthorDate: Thu Oct 9 12:15:58 2025 +0900

    [#8668] improvement(core): prevent handing out new clients after pool 
closure (#8682)
    
    ### What changes were proposed in this pull request?
    
    - Fixed an issue in `ClientPoolImpl#get` where a new client could still
    be returned after the pool was closed.
    - Modified the loop to re-check the `closed` flag to ensure no new
    clients are created or returned after pool closure.
    
    ### Why are the changes needed?
    
    Improved so that when the pool is closed, `get()` calls fail and throw
    an exception.
    
    Fix: #8668
    
    ### Does this PR introduce _any_ user-facing change?
    
    No user-facing changes.
    
    ### How was this patch tested?
    
    Executed existing unit tests
    
    ---------
    
    Co-authored-by: Mini Yu <[email protected]>
---
 core/src/main/java/org/apache/gravitino/utils/ClientPoolImpl.java | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/core/src/main/java/org/apache/gravitino/utils/ClientPoolImpl.java 
b/core/src/main/java/org/apache/gravitino/utils/ClientPoolImpl.java
index 5aa0528ee3..ae2cd9910e 100644
--- a/core/src/main/java/org/apache/gravitino/utils/ClientPoolImpl.java
+++ b/core/src/main/java/org/apache/gravitino/utils/ClientPoolImpl.java
@@ -18,7 +18,6 @@
  */
 package org.apache.gravitino.utils;
 
-import com.google.common.base.Preconditions;
 import java.io.Closeable;
 import java.util.ArrayDeque;
 import java.util.Deque;
@@ -131,8 +130,10 @@ public abstract class ClientPoolImpl<C, E extends 
Exception>
   }
 
   private C get() throws InterruptedException {
-    Preconditions.checkState(!closed, "Cannot get a client from a closed 
pool");
     while (true) {
+      if (closed) {
+        throw new IllegalArgumentException("Cannot get a client from a closed 
pool");
+      }
       if (!clients.isEmpty() || currentSize < poolSize) {
         synchronized (this) {
           if (!clients.isEmpty()) {

Reply via email to