@@ -159,15 +159,12 @@ void testCollectDetailedStatisticsConfiguration() {
159159 // Test configuration through config object
160160 final GenericObjectPoolConfig <String > config = new GenericObjectPoolConfig <>();
161161 config .setCollectDetailedStatistics (false );
162-
163162 try (GenericObjectPool <String , TestException > testPool = new GenericObjectPool <>(factory , config )) {
164163 assertFalse (testPool .getCollectDetailedStatistics ());
165164 }
166-
167165 // Test runtime configuration
168166 pool .setCollectDetailedStatistics (false );
169167 assertFalse (pool .getCollectDetailedStatistics ());
170-
171168 pool .setCollectDetailedStatistics (true );
172169 assertTrue (pool .getCollectDetailedStatistics ());
173170 }
@@ -176,23 +173,18 @@ void testCollectDetailedStatisticsConfiguration() {
176173 void testCollectDetailedStatisticsDisabled () throws Exception {
177174 // Configure pool to disable detailed statistics
178175 pool .setCollectDetailedStatistics (false );
179-
180176 final DefaultPooledObject <String > pooledObject = (DefaultPooledObject <String >) factory .makeObject ();
181-
182177 // Record initial values
183178 final long initialActiveTime = pool .getMeanActiveTimeMillis ();
184179 final long initialIdleTime = pool .getMeanIdleDuration ().toMillis ();
185180 final long initialWaitTime = pool .getMeanBorrowWaitTimeMillis ();
186181 final long initialMaxWaitTime = pool .getMaxBorrowWaitTimeMillis ();
187-
188182 // Update statistics - should be ignored for detailed stats
189183 pool .updateStatsBorrow (pooledObject , Duration .ofMillis (100 ));
190184 pool .updateStatsReturn (Duration .ofMillis (200 ));
191-
192185 // Basic counters should still work
193186 assertEquals (1 , pool .getBorrowedCount ());
194187 assertEquals (1 , pool .getReturnedCount ());
195-
196188 // Detailed statistics should remain unchanged
197189 assertEquals (initialActiveTime , pool .getMeanActiveTimeMillis ());
198190 assertEquals (initialIdleTime , pool .getMeanIdleDuration ().toMillis ());
@@ -224,24 +216,19 @@ void testCollectDetailedStatisticsEnabled() throws Exception {
224216 @ Test
225217 void testCollectDetailedStatisticsToggling () throws Exception {
226218 final DefaultPooledObject <String > pooledObject = (DefaultPooledObject <String >) factory .makeObject ();
227-
228219 // Start with detailed stats enabled
229220 pool .setCollectDetailedStatistics (true );
230221 pool .updateStatsBorrow (pooledObject , Duration .ofMillis (50 ));
231222 pool .updateStatsReturn (Duration .ofMillis (100 ));
232-
233223 assertEquals (50 , pool .getMeanBorrowWaitTimeMillis ());
234224 assertEquals (100 , pool .getMeanActiveTimeMillis ());
235-
236225 // Disable detailed stats
237226 pool .setCollectDetailedStatistics (false );
238227 pool .updateStatsBorrow (pooledObject , Duration .ofMillis (200 ));
239228 pool .updateStatsReturn (Duration .ofMillis (300 ));
240-
241229 // Detailed stats should remain at previous values
242230 assertEquals (50 , pool .getMeanBorrowWaitTimeMillis ());
243231 assertEquals (100 , pool .getMeanActiveTimeMillis ());
244-
245232 // Basic counters should continue to increment
246233 assertEquals (2 , pool .getBorrowedCount ());
247234 assertEquals (2 , pool .getReturnedCount ());
@@ -255,19 +242,15 @@ void testStatsStoreConcurrentAccess() throws Exception {
255242 final ExecutorService executor = Executors .newFixedThreadPool (numThreads );
256243 final CountDownLatch startLatch = new CountDownLatch (1 );
257244 final CountDownLatch completeLatch = new CountDownLatch (numThreads );
258-
259245 final List <Future <Void >> futures = new ArrayList <>();
260-
261246 // Create threads that will concurrently update statistics
262247 for (int i = 0 ; i < numThreads ; i ++) {
263248 final int threadId = i ;
264249 futures .add (executor .submit (() -> {
265250 try {
266251 final DefaultPooledObject <String > pooledObject = (DefaultPooledObject <String >) factory .makeObject ();
267-
268252 // Wait for all threads to be ready
269253 startLatch .await ();
270-
271254 // Perform concurrent operations
272255 for (int j = 0 ; j < operationsPerThread ; j ++) {
273256 pool .updateStatsBorrow (pooledObject , Duration .ofMillis (threadId * 10 + j ));
@@ -281,22 +264,17 @@ void testStatsStoreConcurrentAccess() throws Exception {
281264 return null ;
282265 }));
283266 }
284-
285267 // Start all threads simultaneously
286268 startLatch .countDown ();
287-
288269 // Wait for completion
289270 assertTrue (completeLatch .await (30 , TimeUnit .SECONDS ), "Concurrent test should complete within 30 seconds" );
290-
291271 // Verify no exceptions occurred
292272 for (Future <Void > future : futures ) {
293273 future .get (); // Will throw if there was an exception
294274 }
295-
296275 // Verify that statistics were collected (exact values may vary due to race conditions)
297276 assertEquals (numThreads * operationsPerThread , pool .getBorrowedCount ());
298277 assertEquals (numThreads * operationsPerThread , pool .getReturnedCount ());
299-
300278 // Mean values should be reasonable (not zero or wildly incorrect)
301279 assertTrue (pool .getMeanActiveTimeMillis () >= 0 );
302280 assertTrue (pool .getMeanBorrowWaitTimeMillis () >= 0 );
@@ -310,19 +288,16 @@ void testStatsStoreConcurrentAccess() throws Exception {
310288 void testStatsStoreCircularBuffer () throws Exception {
311289 // Test that StatsStore properly handles circular buffer behavior
312290 final DefaultPooledObject <String > pooledObject = (DefaultPooledObject <String >) factory .makeObject ();
313-
314291 // Fill beyond the cache size (100) to test circular behavior
315292 final int cacheSize = 100 ; // BaseGenericObjectPool.MEAN_TIMING_STATS_CACHE_SIZE
316293 for (int i = 0 ; i < cacheSize + 50 ; i ++) {
317294 pool .updateStatsBorrow (pooledObject , Duration .ofMillis (i ));
318295 pool .updateStatsReturn (Duration .ofMillis (i * 2 ));
319296 }
320-
321297 // Statistics should still be meaningful after circular buffer wrapping
322298 assertTrue (pool .getMeanActiveTimeMillis () > 0 );
323299 assertTrue (pool .getMeanBorrowWaitTimeMillis () > 0 );
324300 assertTrue (pool .getMaxBorrowWaitTimeMillis () > 0 );
325-
326301 // The mean should reflect recent values, not all historical values
327302 // (exact assertion depends on circular buffer implementation)
328303 assertTrue (pool .getMeanBorrowWaitTimeMillis () >= 50 ); // Should be influenced by recent higher values
@@ -333,11 +308,9 @@ void testDetailedStatisticsConfigIntegration() {
333308 // Test that config property is properly applied during pool construction
334309 final GenericObjectPoolConfig <String > config = new GenericObjectPoolConfig <>();
335310 config .setCollectDetailedStatistics (false );
336-
337311 try (GenericObjectPool <String , TestException > testPool = new GenericObjectPool <>(factory , config )) {
338312 assertFalse (testPool .getCollectDetailedStatistics (),
339313 "Pool should respect collectDetailedStatistics setting from config" );
340-
341314 // Test that toString includes the new property
342315 final String configString = config .toString ();
343316 assertTrue (configString .contains ("collectDetailedStatistics" ),
0 commit comments