shengulong created POOL-422:
-------------------------------

             Summary: GenericObjectPool.create
                 Key: POOL-422
                 URL: https://issues.apache.org/jira/browse/POOL-422
             Project: Commons Pool
          Issue Type: Improvement
    Affects Versions: 2.12.1
            Reporter: shengulong


private PooledObject<T> create(final Duration maxWaitDuration) throws Exception 
{

        final Instant startInstant = Instant.now();
        
        Duration remainingWaitDuration =
                maxWaitDuration.isNegative() ? Duration.ZERO : maxWaitDuration;
        
        int localMaxTotal = getMaxTotal();
        // This simplifies the code later in this method
        if (localMaxTotal < 0) {
            localMaxTotal = Integer.MAX_VALUE;
        }
        
        final Instant localStartInstant = Instant.now();
        // Flag that indicates if create should:
        // - TRUE: call the factory to create an object 创建一个对象
        // - FALSE: return null 不创建对象
        // - null: loop and re-test the condition that determines whether to
        //          call the factory 循环确认是否需要创建对象
        Boolean create = null;

        
        while (create == null) {
            // remainingWaitDuration handles spurious wakeup from wait().       
     
            remainingWaitDuration = 
remainingWaitDuration.minus(durationSince(startInstant));

            ...
        }

        ...        

}     

 

should be:

 

private PooledObject<T> create(final Duration maxWaitDuration) throws Exception 
{

        final Instant startInstant = Instant.now();
        
        Duration maxWaitDuration =
                maxWaitDuration.isNegative() ? Duration.ZERO : maxWaitDuration;
        
        int localMaxTotal = getMaxTotal();
        // This simplifies the code later in this method
        if (localMaxTotal < 0) {
            localMaxTotal = Integer.MAX_VALUE;
        }
        
        final Instant localStartInstant = Instant.now();
        // Flag that indicates if create should:
        // - TRUE: call the factory to create an object 创建一个对象
        // - FALSE: return null 不创建对象
        // - null: loop and re-test the condition that determines whether to
        //          call the factory 循环确认是否需要创建对象
        Boolean create = null;

        
        while (create == null) {
            // remainingWaitDuration handles spurious wakeup from wait().       
     
            remainingWaitDuration = 
maxWaitDuration.minus(durationSince(startInstant));

            ...
        }

        ...        

}      



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to