aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorezhil <ezhrajam@in.ibm.com>2018-12-26 15:55:51 +0530
committerezhil <ezhrajam@in.ibm.com>2018-12-26 15:56:04 +0530
commit6c1dee5b7d0e66338100c65efd51917d4f69998f (patch)
treeb6f88afa42a11027f7e19a942fbf73209fc3ad41
parent5df4fb30eaf3bbbd6ac5802a8f75fcf8c19d4e6f (diff)
Fixed sonar fix in DataSourceWrap.java
Fixed major bug Issue-ID: CCSDK-838 Change-Id: Iee8ce39e54f15f33e9d682068d721fb56610d12c Signed-off-by: ezhil <ezhrajam@in.ibm.com>
-rw-r--r--resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/util/db/DataSourceWrap.java26
1 files changed, 12 insertions, 14 deletions
diff --git a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/util/db/DataSourceWrap.java b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/util/db/DataSourceWrap.java
index 2aebb83e..259b9d8d 100644
--- a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/util/db/DataSourceWrap.java
+++ b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/util/db/DataSourceWrap.java
@@ -4,6 +4,7 @@
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights
* reserved.
+ * Modifications Copyright (C) 2018 IBM.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -74,25 +75,22 @@ public class DataSourceWrap implements DataSource {
@Override
public Connection getConnection() throws SQLException {
- Connection c = dataSource.getConnection();
-
- log.debug("getConnection: " + c.getClass().getName());
-
- c.setAutoCommit(true);
- return c;
+ try (Connection c = dataSource.getConnection()){
+ log.debug("getConnection: " + c.getClass().getName());
+ c.setAutoCommit(true);
+ return c;
+ }
}
-
@Override
public Connection getConnection(String username, String password) throws SQLException {
- Connection c = dataSource.getConnection(username, password);
-
- log.debug("getConnection: " + c.getClass().getName());
-
- c.setAutoCommit(true);
- return c;
+ try (Connection c = dataSource.getConnection(username, password)){
+ log.debug("getConnection: " + c.getClass().getName());
+ c.setAutoCommit(true);
+ return c;
+ }
}
- public void setDataSource(DataSource dataSource) {
+ public void setDataSource(DataSource dataSource) {
this.dataSource = dataSource;
}
}