commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Phil Steitz (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (DBCP-438) Nested connections in a transaction (local) throws null pointer
Date Sun, 12 Jul 2015 15:24:04 GMT

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

Phil Steitz commented on DBCP-438:
----------------------------------

Adding the null check to DelegatingConnection#closeInternal  fixes the reported issue here
(and is probably not a bad idea in any case), but I suspect that what is really going on here
is that we don't correctly support the use case in the example.  I am not a JTA expert, so
could use some help reviewing the code in ManagedConnection.  It looks to me like the code
in this example triggers incorrect (at least incomprehensible to me) behavior in ManagedConnection#updateTransactionStatus.
 Looks to me like the first connection will get closed and returned to the pool when the second
one is opened.   

> Nested connections in a transaction (local) throws null pointer
> ---------------------------------------------------------------
>
>                 Key: DBCP-438
>                 URL: https://issues.apache.org/jira/browse/DBCP-438
>             Project: Commons Dbcp
>          Issue Type: Bug
>    Affects Versions: 2.0, 2.1
>         Environment: All (linux, aix, windows)
>            Reporter: Raihan Kibria
>             Fix For: 2.1.1
>
>         Attachments: TestManagedDataSourceInNesetedConnTx.java, dbcpNull.png
>
>
> In a transaction context, if we open multiple connections and close each of them after
commit, we get a null pointer exception. Sample code:
> 		transactionManager.begin();
> 		
> 		Connection c1 = null;
> 		Connection c2 = null;
> 		
> 		c1 = newConnection();
> 		c2 = newConnection();
> 		
> 		transactionManager.commit();
> 		
> 		try{
> 			c1.close();
> 		}catch(Exception e){
> 			e.printStackTrace();
> 		}
> 		
> 		try{
> 			c2.close();
> 		}catch(Exception e){
> 			//throws execption
> 			e.printStackTrace();
> 		}
> Null pointer is thrown at:
> org.apache.commons.dbcp2.DelegatingConnection.closeInternal
> Affects versions-- 2.1, 2.0



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

Mime
View raw message