fineract-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nazeer1100...@apache.org
Subject fineract git commit: Fixing Connection abandoned with Column Validator
Date Thu, 18 May 2017 10:42:57 GMT
Repository: fineract
Updated Branches:
  refs/heads/1.0.0 0d7cf3a28 -> 3f0d653d3


Fixing Connection abandoned with Column Validator


Project: http://git-wip-us.apache.org/repos/asf/fineract/repo
Commit: http://git-wip-us.apache.org/repos/asf/fineract/commit/3f0d653d
Tree: http://git-wip-us.apache.org/repos/asf/fineract/tree/3f0d653d
Diff: http://git-wip-us.apache.org/repos/asf/fineract/diff/3f0d653d

Branch: refs/heads/1.0.0
Commit: 3f0d653d3af1732082791f5082e8d71d1cb4d089
Parents: 0d7cf3a
Author: Nazeer Hussain Shaik <nazeer.shaik@confluxtechnologies.com>
Authored: Thu May 18 16:10:11 2017 +0530
Committer: Nazeer Hussain Shaik <nazeer.shaik@confluxtechnologies.com>
Committed: Thu May 18 16:10:11 2017 +0530

----------------------------------------------------------------------
 .../infrastructure/security/utils/ColumnValidator.java | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/fineract/blob/3f0d653d/fineract-provider/src/main/java/org/apache/fineract/infrastructure/security/utils/ColumnValidator.java
----------------------------------------------------------------------
diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/security/utils/ColumnValidator.java
b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/security/utils/ColumnValidator.java
index 6e1b0cb..c2a261a 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/security/utils/ColumnValidator.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/security/utils/ColumnValidator.java
@@ -18,6 +18,7 @@
  */
 package org.apache.fineract.infrastructure.security.utils;
 
+import java.sql.Connection;
 import java.sql.DatabaseMetaData;
 import java.sql.ResultSet;
 import java.sql.SQLException;
@@ -32,6 +33,7 @@ import java.util.Set;
 import org.apache.fineract.infrastructure.core.service.RoutingDataSource;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.jdbc.datasource.DataSourceUtils;
 import org.springframework.stereotype.Component;
 
 @Component
@@ -45,9 +47,11 @@ public class ColumnValidator {
 	}
 
 	private void validateColumn(Map<String, Set<String>> tableColumnMap) {
+		Connection connection = null ;
 		try {
-			DatabaseMetaData dbMetaData = this.jdbcTemplate.getDataSource()
-					.getConnection().getMetaData();
+			connection = this.jdbcTemplate.getDataSource()
+					.getConnection() ;
+			DatabaseMetaData dbMetaData = connection.getMetaData();
 			ResultSet resultSet = null;
 			for (HashMap.Entry<String, Set<String>> entry : tableColumnMap
 					.entrySet()) {
@@ -66,6 +70,11 @@ public class ColumnValidator {
 			}
 		} catch (SQLException e) {
 			throw new SQLInjectionException();
+		}finally {
+			if(connection != null) {
+				DataSourceUtils.releaseConnection(connection, jdbcTemplate.getDataSource());
+			}
+			connection = null ;
 		}
 	}
 


Mime
View raw message