summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Timoney <dtimoney@att.com>2018-12-28 02:47:55 +0000
committerGerrit Code Review <gerrit@onap.org>2018-12-28 02:47:55 +0000
commit758b84fceb1c23ded8b8392dccb7b40fbbb7bafd (patch)
tree4afba7e830bbf1fbd228e4b6f03e704d962093d2
parent0dfcae05c64111313f93635a1b9e290370015a95 (diff)
parent6c1dee5b7d0e66338100c65efd51917d4f69998f (diff)
Merge "Fixed sonar fix in DataSourceWrap.java"
-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 2aebb83e3..259b9d8d9 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;
}
}