Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id AC6FD200C78 for ; Thu, 18 May 2017 12:42:59 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id AAF06160BC4; Thu, 18 May 2017 10:42:59 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id F080A160BB0 for ; Thu, 18 May 2017 12:42:58 +0200 (CEST) Received: (qmail 92623 invoked by uid 500); 18 May 2017 10:42:58 -0000 Mailing-List: contact commits-help@fineract.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@fineract.apache.org Delivered-To: mailing list commits@fineract.apache.org Received: (qmail 92612 invoked by uid 99); 18 May 2017 10:42:58 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 18 May 2017 10:42:58 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 04CC3DFF17; Thu, 18 May 2017 10:42:57 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: nazeer1100126@apache.org To: commits@fineract.apache.org Message-Id: <9e9c6a2bf62646dab3f2bbc6155122a2@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: fineract git commit: Fixing Connection abandoned with Column Validator Date: Thu, 18 May 2017 10:42:57 +0000 (UTC) archived-at: Thu, 18 May 2017 10:42:59 -0000 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 Authored: Thu May 18 16:10:11 2017 +0530 Committer: Nazeer Hussain Shaik 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> 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> 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 ; } }