Skip to content

Commit d46c1f6

Browse files
committed
TransactionAwareDataSourceProxy processes isClosed explicitly in order to avoid potential leaks (SPR-5780)
1 parent 2b962e7 commit d46c1f6

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2008 the original author or authors.
2+
* Copyright 2002-2009 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -22,7 +22,6 @@
2222
import java.lang.reflect.Proxy;
2323
import java.sql.Connection;
2424
import java.sql.SQLException;
25-
2625
import javax.sql.DataSource;
2726

2827
import org.apache.commons.logging.Log;
@@ -346,7 +345,7 @@ else if (method.getName().equals("clearWarnings")) {
346345
return null;
347346
}
348347
else if (method.getName().equals("isClosed")) {
349-
return (this.closed);
348+
return this.closed;
350349
}
351350
else if (method.getName().equals("close")) {
352351
// Ignore: no target connection yet.

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2008 the original author or authors.
2+
* Copyright 2002-2009 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -61,7 +61,7 @@ public class SingleConnectionDataSource extends DriverManagerDataSource
6161
/** Create a close-suppressing proxy? */
6262
private boolean suppressClose;
6363

64-
/** Override AutoCommit? */
64+
/** Override auto-commit state? */
6565
private Boolean autoCommit;
6666

6767
/** Wrapped Connection */

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2008 the original author or authors.
2+
* Copyright 2002-2009 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -23,7 +23,6 @@
2323
import java.sql.Connection;
2424
import java.sql.SQLException;
2525
import java.sql.Statement;
26-
2726
import javax.sql.DataSource;
2827

2928
import org.springframework.transaction.support.TransactionSynchronizationManager;
@@ -196,6 +195,9 @@ else if (method.getName().equals("toString")) {
196195
sb.append(" from DataSource [").append(this.targetDataSource).append("]");
197196
}
198197
}
198+
else if (method.getName().equals("isClosed")) {
199+
return this.closed;
200+
}
199201
else if (method.getName().equals("close")) {
200202
// Handle close method: only close if not within a transaction.
201203
DataSourceUtils.doReleaseConnection(this.target, this.targetDataSource);

0 commit comments

Comments
 (0)