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

Mark Thomas commented on POOL-336:
----------------------------------

Catching Throwable is generally a bad idea. The current code is written on the 
basis that if a Throwable is thrown then that represents a fatal error so there 
is no point catching it. The view was that if object factories (or the code 
they call) are routinely throwing java.lang.Error then that is a bug and should 
be fixed at source.

In the JDBC driver case the options are: a) raise a bug against the driver, b) 
add protection in DBCP or c) add protection in POOL. My slight preference 
remains for a) but I don't object to adding protection if that is the way the 
community wants to go.

If we are going to go the protection route then I think it makes more sense in 
POOL than in DBCP since that would be a more general fix. I don't see an 
argument for providing the protection only in DBCP.

If Throwable protection is added then it needs to be added consistently - i.e. 
to all locations that call external code.

Throwable protection also needs to include code along these lines:
https://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/ExceptionUtils.java?view=annotate#l28
to ensure that Throwables that are truly fatal are handled as such and that 
Throwables that are recoverable are treated more like Exception.

> GenericObjectPool's borrowObject lock if create() fails with Error
> ------------------------------------------------------------------
>
>                 Key: POOL-336
>                 URL: https://issues.apache.org/jira/browse/POOL-336
>             Project: Commons Pool
>          Issue Type: Bug
>    Affects Versions: 2.4.3, 2.5.0
>         Environment: mariadb-connector-j
>            Reporter: Wolfgang Glas
>              Labels: patch
>             Fix For: 2.5.1
>
>         Attachments: 0001-Add-a-test-case-for-POOL-336.patch, 
> 0002-Fix-POOL-336.patch
>
>
> We've spotted exactly the same problem as described in POOL-303 for a pool 
> using mariadb-connector-j-2.1.2 with a pool configured to a size, which 
> exactly reflects the normal quantity of used DB connections. 
> After weeks of monitoring the situation, we were able to see the same problem 
> as described in POOL-303. After some more drilldown efforts we concluded, 
> that the problem is triggered, because mariadb-connector-j throws instances 
> of Throwables derived from {{java.lang.Error}}, which are not instances of 
> {{java.lang.Execption}}.
> This leads to a leak of {{makeCount}} in GenericObjectPool.create(), because 
> {{makeCount}} is only decremented, when an instance of 
> {{java.lang.Exception}} is thrown and not when an instance of 
> {{java.langError}} is thrown.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to