commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Phil Yang (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (POOL-303) GenericObjectPool's borrowObject may stuck if create() always fail
Date Mon, 29 Feb 2016 09:32:18 GMT

    [ https://issues.apache.org/jira/browse/POOL-303?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15171638#comment-15171638
] 

Phil Yang commented on POOL-303:
--------------------------------

Hi guys, any one can help me to review this patch? Thanks:)

> GenericObjectPool's borrowObject may stuck if create() always fail
> ------------------------------------------------------------------
>
>                 Key: POOL-303
>                 URL: https://issues.apache.org/jira/browse/POOL-303
>             Project: Commons Pool
>          Issue Type: Bug
>            Reporter: Phil Yang
>         Attachments: 303.txt
>
>
> If GenericObjectPool's user use borrowObject() to get the object. The pool will try to
pollFirst() first and if there is no idle object it will try to create it. In create()  if
createCount > maxTotal, it will not create any object and wait on idleObjects.takeFirst()
or idleObjects.pollFirst(borrowMaxWaitMillis, TimeUnit.MILLISECONDS) for other thread return
an object. 
> If there are many threads (the number is more than maxTotal) to borrowObject concurrently,
there will only maxTotal threads go to create the object, the others will wait on the queue.
However, if the factory has some problem that makeObject() always throw Exception, there will
not be any object created so no thread will return the object that should send a signal to
one waiting thread. The thread wait on idleObjects.takeFirst()  will stuck forever because
it has no timeout.
> I think it can be fixed by adding a idleObjects.interuptTakeWaiters(); in create() before
it throws the exception and let the waiting threads interrupted and retry to create.  
> It seems that all 2.x version affected?



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message