Browse Source

TransactionAwareDataSourceProxy processes isClosed explicitly in order to avoid potential leaks (SPR-5780)

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@2337 50f2f4bb-b051-0410-bef5-90022cba6387
pull/1/head
Juergen Hoeller 16 years ago
parent
commit
69a72e8c72
  1. 5
      org.springframework.jdbc/src/main/java/org/springframework/jdbc/datasource/LazyConnectionDataSourceProxy.java
  2. 4
      org.springframework.jdbc/src/main/java/org/springframework/jdbc/datasource/SingleConnectionDataSource.java
  3. 6
      org.springframework.jdbc/src/main/java/org/springframework/jdbc/datasource/TransactionAwareDataSourceProxy.java

5
org.springframework.jdbc/src/main/java/org/springframework/jdbc/datasource/LazyConnectionDataSourceProxy.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2009 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -22,7 +22,6 @@ import java.lang.reflect.Method; @@ -22,7 +22,6 @@ import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.sql.Connection;
import java.sql.SQLException;
import javax.sql.DataSource;
import org.apache.commons.logging.Log;
@ -346,7 +345,7 @@ public class LazyConnectionDataSourceProxy extends DelegatingDataSource { @@ -346,7 +345,7 @@ public class LazyConnectionDataSourceProxy extends DelegatingDataSource {
return null;
}
else if (method.getName().equals("isClosed")) {
return (this.closed);
return this.closed;
}
else if (method.getName().equals("close")) {
// Ignore: no target connection yet.

4
org.springframework.jdbc/src/main/java/org/springframework/jdbc/datasource/SingleConnectionDataSource.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2009 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -61,7 +61,7 @@ public class SingleConnectionDataSource extends DriverManagerDataSource @@ -61,7 +61,7 @@ public class SingleConnectionDataSource extends DriverManagerDataSource
/** Create a close-suppressing proxy? */
private boolean suppressClose;
/** Override AutoCommit? */
/** Override auto-commit state? */
private Boolean autoCommit;
/** Wrapped Connection */

6
org.springframework.jdbc/src/main/java/org/springframework/jdbc/datasource/TransactionAwareDataSourceProxy.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2009 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -23,7 +23,6 @@ import java.lang.reflect.Proxy; @@ -23,7 +23,6 @@ import java.lang.reflect.Proxy;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import javax.sql.DataSource;
import org.springframework.transaction.support.TransactionSynchronizationManager;
@ -196,6 +195,9 @@ public class TransactionAwareDataSourceProxy extends DelegatingDataSource { @@ -196,6 +195,9 @@ public class TransactionAwareDataSourceProxy extends DelegatingDataSource {
sb.append(" from DataSource [").append(this.targetDataSource).append("]");
}
}
else if (method.getName().equals("isClosed")) {
return this.closed;
}
else if (method.getName().equals("close")) {
// Handle close method: only close if not within a transaction.
DataSourceUtils.doReleaseConnection(this.target, this.targetDataSource);

Loading…
Cancel
Save