kroosxu opened a new pull request, #4798:
URL: https://github.com/apache/bookkeeper/pull/4798

   
   Descriptions of the changes in this PR:
   
   Fix #4797
   
   ### Motivation
   
   When `BookKeeper.forConfig(conf).build()` fails part-way through construction
   (for example because `metadataServiceUri` points to an unreachable or invalid
   ZooKeeper ensemble, or `MetadataDrivers#getClientDriver(URI)` cannot resolve
   a driver for the configured scheme), the constructor leaks every resource it
   has already allocated up to the point of failure.
   
   ### Changes
   
   - In the `BookKeeper` constructor, when initialization fails *after* the
     worker pools / bookie client have been created but *before* the object is
     fully constructed, invoke `close()` on the partially-initialized instance
     so that all already-allocated resources are
     shut down before the exception is propagated to the caller.
   
   - Add `BookKeeperConstructorFailureTest` under
     `bookkeeper-server/src/test/java/org/apache/bookkeeper/client/` covering
     the regression:
     - `testNoThreadLeakWhenMetadataServiceUnavailable` — a single failing
       `build()` must not leave any client-owned thread behind.
     - `testRepeatedFailedBuildsDoNotAccumulateThreads` — 20 consecutive
       failing `build()` calls must not accumulate threads.


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