提交 d46c1f60 编写于 作者: J Juergen Hoeller

TransactionAwareDataSourceProxy processes isClosed explicitly in order to...

TransactionAwareDataSourceProxy processes isClosed explicitly in order to avoid potential leaks (SPR-5780)
上级 2b962e77
/*
* 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;
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 {
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.
......
/*
* 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
/** Create a close-suppressing proxy? */
private boolean suppressClose;
/** Override AutoCommit? */
/** Override auto-commit state? */
private Boolean autoCommit;
/** Wrapped Connection */
......
/*
* 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;
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 {
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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册