From 65dc1d5dbae779939eb45e7aad70110acf260d85 Mon Sep 17 00:00:00 2001 From: Daan Hoogland Date: Sun, 2 Aug 2015 12:48:34 +0200 Subject: [PATCH 01/12] CLOUDSTACK-8656: handle template properties loading --- .../storage/template/TemplateLocation.java | 24 ++++--------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/core/src/com/cloud/storage/template/TemplateLocation.java b/core/src/com/cloud/storage/template/TemplateLocation.java index 87f56b8a79bf..ea785b206bdd 100644 --- a/core/src/com/cloud/storage/template/TemplateLocation.java +++ b/core/src/com/cloud/storage/template/TemplateLocation.java @@ -94,17 +94,10 @@ public boolean purge() { } public boolean load() throws IOException { - FileInputStream strm = null; - try { - strm = new FileInputStream(_file); + try (FileInputStream strm = new FileInputStream(_file);) { _props.load(strm); - } finally { - if (strm != null) { - try { - strm.close(); - } catch (IOException e) { - } - } + } catch (IOException e) { + s_logger.warn("Unable to load the template properties", e); } for (ImageFormat format : ImageFormat.values()) { @@ -142,20 +135,11 @@ public boolean save() { _props.setProperty(info.format.getFileExtension() + ".size", Long.toString(info.size)); _props.setProperty(info.format.getFileExtension() + ".virtualsize", Long.toString(info.virtualSize)); } - FileOutputStream strm = null; - try { - strm = new FileOutputStream(_file); + try (FileOutputStream strm = new FileOutputStream(_file);) { _props.store(strm, ""); } catch (IOException e) { s_logger.warn("Unable to save the template properties ", e); return false; - } finally { - if (strm != null) { - try { - strm.close(); - } catch (IOException e) { - } - } } return true; } From 033ac3b1015aa3a20d6700fce75d49bd2e2bd082 Mon Sep 17 00:00:00 2001 From: Daan Hoogland Date: Sun, 2 Aug 2015 12:52:33 +0200 Subject: [PATCH 02/12] CLOUDSTACK-8656: messages on errors closing streams for local templates --- .../com/cloud/storage/template/LocalTemplateDownloader.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/core/src/com/cloud/storage/template/LocalTemplateDownloader.java b/core/src/com/cloud/storage/template/LocalTemplateDownloader.java index 0edfb13d1ec9..d55a4a2ecfef 100644 --- a/core/src/com/cloud/storage/template/LocalTemplateDownloader.java +++ b/core/src/com/cloud/storage/template/LocalTemplateDownloader.java @@ -123,6 +123,7 @@ public long download(boolean resume, DownloadCompleteCallback callback) { try { fic.close(); } catch (IOException e) { + s_logger.info("[ignore] error while closing file input channel."); } } @@ -130,6 +131,7 @@ public long download(boolean resume, DownloadCompleteCallback callback) { try { foc.close(); } catch (IOException e) { + s_logger.info("[ignore] error while closing file output channel."); } } @@ -137,6 +139,7 @@ public long download(boolean resume, DownloadCompleteCallback callback) { try { fis.close(); } catch (IOException e) { + s_logger.info("[ignore] error while closing file input stream."); } } @@ -144,6 +147,7 @@ public long download(boolean resume, DownloadCompleteCallback callback) { try { fos.close(); } catch (IOException e) { + s_logger.info("[ignore] error while closing file output stream."); } } From 89bd6d020fdf359feb1f3c61879011a7dbca9a76 Mon Sep 17 00:00:00 2001 From: Daan Hoogland Date: Sun, 2 Aug 2015 12:55:52 +0200 Subject: [PATCH 03/12] CLOUDSTACK-8656: info on error closing peering channels --- .../src/com/cloud/agent/manager/ClusteredAgentManagerImpl.java | 1 + 1 file changed, 1 insertion(+) diff --git a/engine/orchestration/src/com/cloud/agent/manager/ClusteredAgentManagerImpl.java b/engine/orchestration/src/com/cloud/agent/manager/ClusteredAgentManagerImpl.java index d11612d9ebdd..2bc4f6859c5f 100644 --- a/engine/orchestration/src/com/cloud/agent/manager/ClusteredAgentManagerImpl.java +++ b/engine/orchestration/src/com/cloud/agent/manager/ClusteredAgentManagerImpl.java @@ -585,6 +585,7 @@ public boolean stop() { s_logger.info("Closing: " + ch.toString()); ch.close(); } catch (IOException e) { + s_logger.info("[ignored] error on closing channel: " +ch.toString(), e); } } } From 4e65845789643db29b4a1f1789bbb8e1b8e16859 Mon Sep 17 00:00:00 2001 From: Daan Hoogland Date: Sun, 2 Aug 2015 12:58:56 +0200 Subject: [PATCH 04/12] CLOUDSTACK-8656: removed unused input stream there was code to close a stream that was never created --- .../com/cloud/certificate/dao/CertificateDaoImpl.java | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/engine/schema/src/com/cloud/certificate/dao/CertificateDaoImpl.java b/engine/schema/src/com/cloud/certificate/dao/CertificateDaoImpl.java index a2ec67bf8387..978fee044019 100644 --- a/engine/schema/src/com/cloud/certificate/dao/CertificateDaoImpl.java +++ b/engine/schema/src/com/cloud/certificate/dao/CertificateDaoImpl.java @@ -16,9 +16,6 @@ // under the License. package com.cloud.certificate.dao; -import java.io.BufferedInputStream; -import java.io.IOException; - import javax.ejb.Local; import org.apache.log4j.Logger; @@ -41,7 +38,6 @@ public CertificateDaoImpl() { @Override public Long persistCustomCertToDb(String certStr, CertificateVO cert, Long managementServerId) { - BufferedInputStream f = null; try { cert.setCertificate(certStr); cert.setUpdated("Y"); @@ -50,12 +46,6 @@ public Long persistCustomCertToDb(String certStr, CertificateVO cert, Long manag } catch (Exception e) { s_logger.warn("Unable to read the certificate: " + e); return new Long(0); - } finally { - if (f != null) - try { - f.close(); - } catch (IOException ignored) { - } } } } From 04e9083c3199effa295e47bc617b9b406adb6109 Mon Sep 17 00:00:00 2001 From: Daan Hoogland Date: Sun, 2 Aug 2015 14:20:11 +0200 Subject: [PATCH 05/12] CLOUDSTACK-8656: log messages on exception in legacy sql upgrade code --- .../cloud/upgrade/dao/LegacyDbUpgrade.java | 42 +++ .../cloud/upgrade/dao/Upgrade2214to30.java | 11 +- .../cloud/upgrade/dao/Upgrade222to224.java | 6 + .../cloud/upgrade/dao/Upgrade229to2210.java | 41 +-- .../cloud/upgrade/dao/Upgrade301to302.java | 64 +--- .../cloud/upgrade/dao/Upgrade302to303.java | 59 +--- .../com/cloud/upgrade/dao/Upgrade302to40.java | 326 +++++------------- .../cloud/upgrade/dao/Upgrade304to305.java | 61 +--- .../cloud/upgrade/dao/Upgrade305to306.java | 88 +---- .../cloud/upgrade/dao/Upgrade306to307.java | 16 +- .../cloud/upgrade/dao/Upgrade307to410.java | 11 +- .../com/cloud/upgrade/dao/Upgrade30xBase.java | 73 +--- 12 files changed, 219 insertions(+), 579 deletions(-) create mode 100644 engine/schema/src/com/cloud/upgrade/dao/LegacyDbUpgrade.java diff --git a/engine/schema/src/com/cloud/upgrade/dao/LegacyDbUpgrade.java b/engine/schema/src/com/cloud/upgrade/dao/LegacyDbUpgrade.java new file mode 100644 index 000000000000..e43f1eb35cd2 --- /dev/null +++ b/engine/schema/src/com/cloud/upgrade/dao/LegacyDbUpgrade.java @@ -0,0 +1,42 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +package com.cloud.upgrade.dao; + +import org.apache.log4j.Logger; + +public abstract class LegacyDbUpgrade implements DbUpgrade{ + + final static Logger s_logger = Logger.getLogger(LegacyDbUpgrade.class); + + public LegacyDbUpgrade() { + super(); + } + + /** + * @param closable + */ + protected void closeAutoCloseable(AutoCloseable closable) { + if (closable != null) { + try { + closable.close(); + } catch (Exception e) { + s_logger.info("[ignored]",e); + } + } + } + +} \ No newline at end of file diff --git a/engine/schema/src/com/cloud/upgrade/dao/Upgrade2214to30.java b/engine/schema/src/com/cloud/upgrade/dao/Upgrade2214to30.java index eb4e8c75693f..272d25990d64 100644 --- a/engine/schema/src/com/cloud/upgrade/dao/Upgrade2214to30.java +++ b/engine/schema/src/com/cloud/upgrade/dao/Upgrade2214to30.java @@ -411,6 +411,7 @@ private void encryptConfigValues(Connection conn) { pstmt.close(); } } catch (SQLException e) { + s_logger.info("[ignored]",e); } } s_logger.debug("Done encrypting Config values"); @@ -861,6 +862,7 @@ protected void updateReduntantRouters(Connection conn) { pstmt.executeUpdate(); pstmt.close(); } catch (SQLException e) { + s_logger.info("[ignored]",e); } TransactionLegacy.closePstmts(pstmt2Close); } @@ -1000,6 +1002,7 @@ protected void switchAccountSpecificNetworksToIsolated(Connection conn) { pstmt.executeUpdate(); pstmt.close(); } catch (SQLException e) { + s_logger.info("[ignored]",e); } TransactionLegacy.closePstmts(pstmt2Close); } @@ -1053,6 +1056,7 @@ private void migrateUserConcentratedPlannerChoice(Connection conn) { pstmt.close(); } } catch (SQLException e) { + s_logger.info("[ignored]",e); } } } @@ -1151,11 +1155,10 @@ protected String fixNetworksWithExternalDevices(Connection conn) { } catch (SQLException e) { throw new CloudRuntimeException("Unable to switch networks to the new network offering", e); } finally { - try { - pstmt = conn.prepareStatement("DROP TABLE `cloud`.`network_offerings2`"); - pstmt.executeUpdate(); - pstmt.close(); + try (PreparedStatement dropStatement = conn.prepareStatement("DROP TABLE `cloud`.`network_offerings2`");){ + dropStatement.executeUpdate(); } catch (SQLException e) { + s_logger.info("[ignored]",e); } TransactionLegacy.closePstmts(pstmt2Close); } diff --git a/engine/schema/src/com/cloud/upgrade/dao/Upgrade222to224.java b/engine/schema/src/com/cloud/upgrade/dao/Upgrade222to224.java index dbd48c879e87..458f7eebf413 100644 --- a/engine/schema/src/com/cloud/upgrade/dao/Upgrade222to224.java +++ b/engine/schema/src/com/cloud/upgrade/dao/Upgrade222to224.java @@ -207,18 +207,21 @@ private void updateClusterIdInOpHostCapacity(Connection conn) { try { pstmtUpdate.close(); } catch (SQLException e) { + s_logger.info("[ignored]",e); } } if (rs != null) { try { rs.close(); } catch (SQLException e) { + s_logger.info("[ignored]",e); } } if (pstmt != null) { try { pstmt.close(); } catch (SQLException e) { + s_logger.info("[ignored]",e); } } @@ -406,18 +409,21 @@ private void updateTotalCPUInOpHostCapacity(Connection conn) { try { pstmtUpdate.close(); } catch (SQLException e) { + s_logger.info("[ignored]",e); } } if (rs != null) { try { rs.close(); } catch (SQLException e) { + s_logger.info("[ignored]",e); } } if (pstmt != null) { try { pstmt.close(); } catch (SQLException e) { + s_logger.info("[ignored]",e); } } diff --git a/engine/schema/src/com/cloud/upgrade/dao/Upgrade229to2210.java b/engine/schema/src/com/cloud/upgrade/dao/Upgrade229to2210.java index 2eca446652e9..dbeb31e6b450 100644 --- a/engine/schema/src/com/cloud/upgrade/dao/Upgrade229to2210.java +++ b/engine/schema/src/com/cloud/upgrade/dao/Upgrade229to2210.java @@ -68,41 +68,29 @@ public File[] getCleanupScripts() { } private void updateSnapshots(Connection conn) { - PreparedStatement pstmt = null; - ResultSet rs = null; long currentSnapshotId = 0; - try { - pstmt = - conn.prepareStatement("select id, prev_snap_id from snapshots where sechost_id is NULL and prev_snap_id is not NULL and status=\"BackedUp\" and removed is NULL order by id"); - rs = pstmt.executeQuery(); + try ( + PreparedStatement pstmt = conn.prepareStatement("select id, prev_snap_id from snapshots where sechost_id is NULL and prev_snap_id is not NULL and status=\"BackedUp\" and removed is NULL order by id"); + ResultSet rs = pstmt.executeQuery(); + PreparedStatement pstmt2 = conn.prepareStatement("select sechost_id from snapshots where id=? and sechost_id is not NULL"); + PreparedStatement updateSnapshotStatement = conn.prepareStatement("update snapshots set sechost_id=? where id=?"); + ){ while (rs.next()) { long id = rs.getLong(1); long preSnapId = rs.getLong(2); currentSnapshotId = id; - pstmt = conn.prepareStatement("select sechost_id from snapshots where id=? and sechost_id is not NULL"); - pstmt.setLong(1, preSnapId); - ResultSet sechost = pstmt.executeQuery(); - if (sechost.next()) { - long secHostId = sechost.getLong(1); - pstmt = conn.prepareStatement("update snapshots set sechost_id=? where id=?"); - pstmt.setLong(1, secHostId); - pstmt.setLong(2, id); - pstmt.executeUpdate(); + pstmt2.setLong(1, preSnapId); + try (ResultSet sechost = pstmt2.executeQuery();) { + if (sechost.next()) { + long secHostId = sechost.getLong(1); + updateSnapshotStatement.setLong(1, secHostId); + updateSnapshotStatement.setLong(2, id); + updateSnapshotStatement.executeUpdate(); + } } } } catch (SQLException e) { throw new CloudRuntimeException("Unable to update snapshots id=" + currentSnapshotId, e); - } finally { - try { - if (rs != null) { - rs.close(); - } - - if (pstmt != null) { - pstmt.close(); - } - } catch (SQLException e) { - } } } @@ -192,6 +180,7 @@ private void updateFirewallRules(Connection conn) { pstmt.close(); } } catch (SQLException e) { + s_logger.info("[ignored]",e); } } } diff --git a/engine/schema/src/com/cloud/upgrade/dao/Upgrade301to302.java b/engine/schema/src/com/cloud/upgrade/dao/Upgrade301to302.java index 0da787774b53..0e9b479c9473 100644 --- a/engine/schema/src/com/cloud/upgrade/dao/Upgrade301to302.java +++ b/engine/schema/src/com/cloud/upgrade/dao/Upgrade301to302.java @@ -31,7 +31,7 @@ import com.cloud.utils.exception.CloudRuntimeException; import com.cloud.utils.script.Script; -public class Upgrade301to302 implements DbUpgrade { +public class Upgrade301to302 extends LegacyDbUpgrade { final static Logger s_logger = Logger.getLogger(Upgrade301to302.class); @Override @@ -150,18 +150,9 @@ protected void updateSharedNetworks(Connection conn) { } catch (SQLException e) { throw new CloudRuntimeException("Unable to update shared networks due to exception while executing query " + pstmt, e); } finally { - try { - if (rs != null) { - rs.close(); - } - if (rs1 != null) { - rs1.close(); - } - if (pstmt != null) { - pstmt.close(); - } - } catch (SQLException e) { - } + closeAutoCloseable(rs); + closeAutoCloseable(rs1); + closeAutoCloseable(pstmt); } } @@ -177,55 +168,34 @@ private void fixLastHostIdKey(Connection conn) { DbUpgradeUtils.dropKeysIfExist(conn, "cloud.vm_instance", keys, true); DbUpgradeUtils.dropKeysIfExist(conn, "cloud.vm_instance", keys, false); - PreparedStatement pstmt = null; - try { - pstmt = + try ( + PreparedStatement pstmt = conn.prepareStatement("ALTER TABLE `cloud`.`vm_instance` ADD CONSTRAINT `fk_vm_instance__last_host_id` FOREIGN KEY (`last_host_id`) REFERENCES `host` (`id`)"); + ){ pstmt.executeUpdate(); - pstmt.close(); } catch (SQLException e) { throw new CloudRuntimeException("Unable to insert foreign key in vm_instance table ", e); - } finally { - try { - if (pstmt != null) { - pstmt.close(); - } - } catch (SQLException e) { - } } } private void changeEngine(Connection conn) { s_logger.debug("Fixing engine and row_format for op_lock and op_nwgrp_work tables"); - PreparedStatement pstmt = null; - try { - pstmt = conn.prepareStatement("ALTER TABLE `cloud`.`op_lock` ENGINE=MEMORY, ROW_FORMAT = FIXED"); + String sqlOpLock = "ALTER TABLE `cloud`.`op_lock` ENGINE=MEMORY, ROW_FORMAT = FIXED"; + try ( + PreparedStatement pstmt = conn.prepareStatement(sqlOpLock); + ) { pstmt.executeUpdate(); - pstmt.close(); } catch (Exception e) { - s_logger.debug("Failed do execute the statement " + pstmt + ", moving on as it's not critical fix"); - } finally { - try { - if (pstmt != null) { - pstmt.close(); - } - } catch (SQLException e) { - } + s_logger.debug("Failed do execute the statement " + sqlOpLock + ", moving on as it's not critical fix"); } - try { - pstmt = conn.prepareStatement("ALTER TABLE `cloud`.`op_nwgrp_work` ENGINE=MEMORY, ROW_FORMAT = FIXED"); + String sqlOpNwgrpWork = "ALTER TABLE `cloud`.`op_nwgrp_work` ENGINE=MEMORY, ROW_FORMAT = FIXED"; + try ( + PreparedStatement pstmt = conn.prepareStatement(sqlOpNwgrpWork); + ) { pstmt.executeUpdate(); - pstmt.close(); } catch (Exception e) { - s_logger.debug("Failed do execute the statement " + pstmt + ", moving on as it's not critical fix"); - } finally { - try { - if (pstmt != null) { - pstmt.close(); - } - } catch (SQLException e) { - } + s_logger.debug("Failed do execute the statement " + sqlOpNwgrpWork + ", moving on as it's not critical fix"); } } diff --git a/engine/schema/src/com/cloud/upgrade/dao/Upgrade302to303.java b/engine/schema/src/com/cloud/upgrade/dao/Upgrade302to303.java index 7cc8bc74c91d..abd0c347df3b 100644 --- a/engine/schema/src/com/cloud/upgrade/dao/Upgrade302to303.java +++ b/engine/schema/src/com/cloud/upgrade/dao/Upgrade302to303.java @@ -36,7 +36,7 @@ import com.cloud.utils.exception.CloudRuntimeException; import com.cloud.utils.script.Script; -public class Upgrade302to303 implements DbUpgrade { +public class Upgrade302to303 extends LegacyDbUpgrade { final static Logger s_logger = Logger.getLogger(Upgrade302to303.class); @Override @@ -133,23 +133,10 @@ private void setupExternalNetworkDevices(Connection conn) { } } } - - if (zoneResults != null) { - try { - zoneResults.close(); - } catch (SQLException e) { - } - } - if (zoneSearchStmt != null) { - try { - zoneSearchStmt.close(); - } catch (SQLException e) { - } - } + closeAutoCloseable(zoneResults); + closeAutoCloseable(zoneSearchStmt); } catch (SQLException e) { throw new CloudRuntimeException("Exception while adding PhysicalNetworks", e); - } finally { - } } @@ -176,12 +163,7 @@ private void addF5LoadBalancer(Connection conn, long hostId, long physicalNetwor } catch (SQLException e) { throw new CloudRuntimeException("Exception while adding F5 load balancer device", e); } finally { - if (pstmtUpdate != null) { - try { - pstmtUpdate.close(); - } catch (SQLException e) { - } - } + closeAutoCloseable(pstmtUpdate); } } @@ -206,12 +188,7 @@ private void addSrxFirewall(Connection conn, long hostId, long physicalNetworkId } catch (SQLException e) { throw new CloudRuntimeException("Exception while adding SRX firewall device ", e); } finally { - if (pstmtUpdate != null) { - try { - pstmtUpdate.close(); - } catch (SQLException e) { - } - } + closeAutoCloseable(pstmtUpdate); } } @@ -235,12 +212,7 @@ private void addF5ServiceProvider(Connection conn, long physicalNetworkId, long } catch (SQLException e) { throw new CloudRuntimeException("Exception while adding PhysicalNetworkServiceProvider F5BigIp", e); } finally { - if (pstmtUpdate != null) { - try { - pstmtUpdate.close(); - } catch (SQLException e) { - } - } + closeAutoCloseable(pstmtUpdate); } } @@ -264,12 +236,7 @@ private void addSrxServiceProvider(Connection conn, long physicalNetworkId, long } catch (SQLException e) { throw new CloudRuntimeException("Exception while adding PhysicalNetworkServiceProvider JuniperSRX", e); } finally { - if (pstmtUpdate != null) { - try { - pstmtUpdate.close(); - } catch (SQLException e) { - } - } + closeAutoCloseable(pstmtUpdate); } } @@ -299,16 +266,8 @@ private void encryptConfig(Connection conn) { } catch (UnsupportedEncodingException e) { throw new CloudRuntimeException("Unable encrypt configuration values ", e); } finally { - try { - if (rs != null) { - rs.close(); - } - - if (pstmt != null) { - pstmt.close(); - } - } catch (SQLException e) { - } + closeAutoCloseable(rs); + closeAutoCloseable(pstmt); } s_logger.debug("Done encrypting Config values"); } diff --git a/engine/schema/src/com/cloud/upgrade/dao/Upgrade302to40.java b/engine/schema/src/com/cloud/upgrade/dao/Upgrade302to40.java index 5ce8f3668302..829e99852bac 100644 --- a/engine/schema/src/com/cloud/upgrade/dao/Upgrade302to40.java +++ b/engine/schema/src/com/cloud/upgrade/dao/Upgrade302to40.java @@ -34,7 +34,7 @@ import com.cloud.utils.exception.CloudRuntimeException; import com.cloud.utils.script.Script; -public class Upgrade302to40 extends Upgrade30xBase implements DbUpgrade { +public class Upgrade302to40 extends Upgrade30xBase { final static Logger s_logger = Logger.getLogger(Upgrade302to40.class); @Override @@ -138,33 +138,10 @@ private void correctVRProviders(Connection conn) { } catch (SQLException e) { throw new CloudRuntimeException("Exception while correcting Virtual Router Entries", e); } finally { - if (rsVR != null) { - try { - rsVR.close(); - } catch (SQLException e) { - } - } - - if (pstmtVR != null) { - try { - pstmtVR.close(); - } catch (SQLException e) { - } - } - - if (rs != null) { - try { - rs.close(); - } catch (SQLException e) { - } - } - - if (pstmt != null) { - try { - pstmt.close(); - } catch (SQLException e) { - } - } + closeAutoCloseable(rsVR); + closeAutoCloseable(pstmtVR); + closeAutoCloseable(rs); + closeAutoCloseable(pstmt); } } @@ -398,33 +375,10 @@ private void correctMultiplePhysicaNetworkSetups(Connection conn) { } catch (SQLException e) { throw new CloudRuntimeException("Exception while correcting PhysicalNetwork setup", e); } finally { - if (rsZone != null) { - try { - rsZone.close(); - } catch (SQLException e) { - } - } - - if (pstmtZone != null) { - try { - pstmtZone.close(); - } catch (SQLException e) { - } - } - - if (rs != null) { - try { - rs.close(); - } catch (SQLException e) { - } - } - - if (pstmt != null) { - try { - pstmt.close(); - } catch (SQLException e) { - } - } + closeAutoCloseable(rsZone); + closeAutoCloseable(pstmtZone); + closeAutoCloseable(rs); + closeAutoCloseable(pstmt); } } @@ -510,29 +464,23 @@ private void cloneOfferingAndAddTag(Connection conn, long networkOfferingId, lon } catch (SQLException e) { throw new CloudRuntimeException("Exception while cloning NetworkOffering", e); } finally { + closeAutoCloseable(rs); try { pstmt = conn.prepareStatement("DROP TEMPORARY TABLE `cloud`.`network_offerings2`"); pstmt.executeUpdate(); - - if (rs != null) { - rs.close(); - } - - if (pstmt != null) { - pstmt.close(); - } } catch (SQLException e) { + s_logger.info("[ignored] ",e); } + closeAutoCloseable(pstmt); } } private void addHostDetailsUniqueKey(Connection conn) { s_logger.debug("Checking if host_details unique key exists, if not we will add it"); - PreparedStatement pstmt = null; - ResultSet rs = null; - try { - pstmt = conn.prepareStatement("SHOW INDEX FROM `cloud`.`host_details` WHERE KEY_NAME = 'uk_host_id_name'"); - rs = pstmt.executeQuery(); + try ( + PreparedStatement pstmt = conn.prepareStatement("SHOW INDEX FROM `cloud`.`host_details` WHERE KEY_NAME = 'uk_host_id_name'"); + ResultSet rs = pstmt.executeQuery(); + ) { if (rs.next()) { s_logger.debug("Unique key already exists on host_details - not adding new one"); } else { @@ -545,17 +493,6 @@ private void addHostDetailsUniqueKey(Connection conn) { } } catch (SQLException e) { throw new CloudRuntimeException("Failed to check/update the host_details unique key ", e); - } finally { - try { - if (rs != null) { - rs.close(); - } - - if (pstmt != null) { - pstmt.close(); - } - } catch (SQLException e) { - } } } @@ -602,16 +539,8 @@ private void addVpcProvider(Connection conn) { } catch (SQLException e) { throw new CloudRuntimeException("Unable add VPC physical network service provider ", e); } finally { - try { - if (rs != null) { - rs.close(); - } - - if (pstmt != null) { - pstmt.close(); - } - } catch (SQLException e) { - } + closeAutoCloseable(rs); + closeAutoCloseable(pstmt); } s_logger.debug("Done adding VPC physical network service providers to all physical networks"); } @@ -619,46 +548,33 @@ private void addVpcProvider(Connection conn) { private void updateRouterNetworkRef(Connection conn) { //Encrypt config params and change category to Hidden s_logger.debug("Updating router network ref"); - PreparedStatement pstmt = null; - ResultSet rs = null; - try { - pstmt = conn.prepareStatement("SELECT d.id, d.network_id FROM `cloud`.`domain_router` d, `cloud`.`vm_instance` v " + "WHERE d.id=v.id AND v.removed is NULL"); - rs = pstmt.executeQuery(); + try ( + PreparedStatement pstmt = conn.prepareStatement("SELECT d.id, d.network_id FROM `cloud`.`domain_router` d, `cloud`.`vm_instance` v " + "WHERE d.id=v.id AND v.removed is NULL"); + PreparedStatement pstmt1 = conn.prepareStatement("SELECT guest_type from `cloud`.`networks` where id=?"); + PreparedStatement pstmt2 = conn.prepareStatement("INSERT INTO `cloud`.`router_network_ref` (router_id, network_id, guest_type) " + "VALUES (?, ?, ?)"); + ResultSet rs = pstmt.executeQuery(); + ){ while (rs.next()) { Long routerId = rs.getLong(1); Long networkId = rs.getLong(2); //get the network type - pstmt = conn.prepareStatement("SELECT guest_type from `cloud`.`networks` where id=?"); - pstmt.setLong(1, networkId); - ResultSet rs1 = pstmt.executeQuery(); - rs1.next(); - String networkType = rs1.getString(1); - - //insert the reference - pstmt = conn.prepareStatement("INSERT INTO `cloud`.`router_network_ref` (router_id, network_id, guest_type) " + "VALUES (?, ?, ?)"); - - pstmt.setLong(1, routerId); - pstmt.setLong(2, networkId); - pstmt.setString(3, networkType); - pstmt.executeUpdate(); + pstmt1.setLong(1, networkId); + try (ResultSet rs1 = pstmt1.executeQuery();) { + rs1.next(); + String networkType = rs1.getString(1); + //insert the reference + pstmt2.setLong(1, routerId); + pstmt2.setLong(2, networkId); + pstmt2.setString(3, networkType); + pstmt2.executeUpdate(); + } s_logger.debug("Added reference for router id=" + routerId + " and network id=" + networkId); } } catch (SQLException e) { throw new CloudRuntimeException("Failed to update the router/network reference ", e); - } finally { - try { - if (rs != null) { - rs.close(); - } - - if (pstmt != null) { - pstmt.close(); - } - } catch (SQLException e) { - } } s_logger.debug("Done updating router/network references"); } @@ -768,33 +684,19 @@ private void setupExternalNetworkDevices(Connection conn) { } } - if (zoneResults != null) { - try { - zoneResults.close(); - } catch (SQLException e) { - } - } - if (zoneSearchStmt != null) { - try { - zoneSearchStmt.close(); - } catch (SQLException e) { - } - } + closeAutoCloseable(zoneResults); + closeAutoCloseable(zoneSearchStmt); } catch (SQLException e) { throw new CloudRuntimeException("Exception while adding PhysicalNetworks", e); - } finally { - } } private void addF5LoadBalancer(Connection conn, long hostId, long physicalNetworkId) { - PreparedStatement pstmtUpdate = null; - try { - s_logger.debug("Adding F5 Big IP load balancer with host id " + hostId + " in to physical network" + physicalNetworkId); - String insertF5 = - "INSERT INTO `cloud`.`external_load_balancer_devices` (physical_network_id, host_id, provider_name, " - + "device_name, capacity, is_dedicated, device_state, allocation_state, is_inline, is_managed, uuid) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; - pstmtUpdate = conn.prepareStatement(insertF5); + s_logger.debug("Adding F5 Big IP load balancer with host id " + hostId + " in to physical network" + physicalNetworkId); + String insertF5 = + "INSERT INTO `cloud`.`external_load_balancer_devices` (physical_network_id, host_id, provider_name, " + + "device_name, capacity, is_dedicated, device_state, allocation_state, is_inline, is_managed, uuid) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; + try (PreparedStatement pstmtUpdate = conn.prepareStatement(insertF5);) { pstmtUpdate.setLong(1, physicalNetworkId); pstmtUpdate.setLong(2, hostId); pstmtUpdate.setString(3, "F5BigIp"); @@ -809,24 +711,15 @@ private void addF5LoadBalancer(Connection conn, long hostId, long physicalNetwor pstmtUpdate.executeUpdate(); } catch (SQLException e) { throw new CloudRuntimeException("Exception while adding F5 load balancer device", e); - } finally { - if (pstmtUpdate != null) { - try { - pstmtUpdate.close(); - } catch (SQLException e) { - } - } } } private void addSrxFirewall(Connection conn, long hostId, long physicalNetworkId) { - PreparedStatement pstmtUpdate = null; - try { - s_logger.debug("Adding SRX firewall device with host id " + hostId + " in to physical network" + physicalNetworkId); - String insertSrx = - "INSERT INTO `cloud`.`external_firewall_devices` (physical_network_id, host_id, provider_name, " - + "device_name, capacity, is_dedicated, device_state, allocation_state, uuid) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?)"; - pstmtUpdate = conn.prepareStatement(insertSrx); + s_logger.debug("Adding SRX firewall device with host id " + hostId + " in to physical network" + physicalNetworkId); + String insertSrx = + "INSERT INTO `cloud`.`external_firewall_devices` (physical_network_id, host_id, provider_name, " + + "device_name, capacity, is_dedicated, device_state, allocation_state, uuid) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?)"; + try (PreparedStatement pstmtUpdate = conn.prepareStatement(insertSrx);) { pstmtUpdate.setLong(1, physicalNetworkId); pstmtUpdate.setLong(2, hostId); pstmtUpdate.setString(3, "JuniperSRX"); @@ -839,28 +732,18 @@ private void addSrxFirewall(Connection conn, long hostId, long physicalNetworkId pstmtUpdate.executeUpdate(); } catch (SQLException e) { throw new CloudRuntimeException("Exception while adding SRX firewall device ", e); - } finally { - if (pstmtUpdate != null) { - try { - pstmtUpdate.close(); - } catch (SQLException e) { - } - } } } private void addF5ServiceProvider(Connection conn, long physicalNetworkId, long zoneId) { - PreparedStatement pstmtUpdate = null; - try { - // add physical network service provider - F5BigIp - s_logger.debug("Adding PhysicalNetworkServiceProvider F5BigIp" + " in to physical network" + physicalNetworkId); - String insertPNSP = - "INSERT INTO `cloud`.`physical_network_service_providers` (`uuid`, `physical_network_id` , `provider_name`, `state` ," - + "`destination_physical_network_id`, `vpn_service_provided`, `dhcp_service_provided`, `dns_service_provided`, `gateway_service_provided`," - + "`firewall_service_provided`, `source_nat_service_provided`, `load_balance_service_provided`, `static_nat_service_provided`," - + "`port_forwarding_service_provided`, `user_data_service_provided`, `security_group_service_provided`) VALUES (?,?,?,?,0,0,0,0,0,0,0,1,0,0,0,0)"; - - pstmtUpdate = conn.prepareStatement(insertPNSP); + // add physical network service provider - F5BigIp + s_logger.debug("Adding PhysicalNetworkServiceProvider F5BigIp" + " in to physical network" + physicalNetworkId); + String insertPNSP = + "INSERT INTO `cloud`.`physical_network_service_providers` (`uuid`, `physical_network_id` , `provider_name`, `state` ," + + "`destination_physical_network_id`, `vpn_service_provided`, `dhcp_service_provided`, `dns_service_provided`, `gateway_service_provided`," + + "`firewall_service_provided`, `source_nat_service_provided`, `load_balance_service_provided`, `static_nat_service_provided`," + + "`port_forwarding_service_provided`, `user_data_service_provided`, `security_group_service_provided`) VALUES (?,?,?,?,0,0,0,0,0,0,0,1,0,0,0,0)"; + try (PreparedStatement pstmtUpdate = conn.prepareStatement(insertPNSP);) { pstmtUpdate.setString(1, UUID.randomUUID().toString()); pstmtUpdate.setLong(2, physicalNetworkId); pstmtUpdate.setString(3, "F5BigIp"); @@ -868,28 +751,18 @@ private void addF5ServiceProvider(Connection conn, long physicalNetworkId, long pstmtUpdate.executeUpdate(); } catch (SQLException e) { throw new CloudRuntimeException("Exception while adding PhysicalNetworkServiceProvider F5BigIp", e); - } finally { - if (pstmtUpdate != null) { - try { - pstmtUpdate.close(); - } catch (SQLException e) { - } - } } } private void addSrxServiceProvider(Connection conn, long physicalNetworkId, long zoneId) { - PreparedStatement pstmtUpdate = null; - try { - // add physical network service provider - JuniperSRX - s_logger.debug("Adding PhysicalNetworkServiceProvider JuniperSRX"); - String insertPNSP = - "INSERT INTO `cloud`.`physical_network_service_providers` (`uuid`, `physical_network_id` , `provider_name`, `state` ," - + "`destination_physical_network_id`, `vpn_service_provided`, `dhcp_service_provided`, `dns_service_provided`, `gateway_service_provided`," - + "`firewall_service_provided`, `source_nat_service_provided`, `load_balance_service_provided`, `static_nat_service_provided`," - + "`port_forwarding_service_provided`, `user_data_service_provided`, `security_group_service_provided`) VALUES (?,?,?,?,0,0,0,0,1,1,1,0,1,1,0,0)"; - - pstmtUpdate = conn.prepareStatement(insertPNSP); + // add physical network service provider - JuniperSRX + s_logger.debug("Adding PhysicalNetworkServiceProvider JuniperSRX"); + String insertPNSP = + "INSERT INTO `cloud`.`physical_network_service_providers` (`uuid`, `physical_network_id` , `provider_name`, `state` ," + + "`destination_physical_network_id`, `vpn_service_provided`, `dhcp_service_provided`, `dns_service_provided`, `gateway_service_provided`," + + "`firewall_service_provided`, `source_nat_service_provided`, `load_balance_service_provided`, `static_nat_service_provided`," + + "`port_forwarding_service_provided`, `user_data_service_provided`, `security_group_service_provided`) VALUES (?,?,?,?,0,0,0,0,1,1,1,0,1,1,0,0)"; + try (PreparedStatement pstmtUpdate = conn.prepareStatement(insertPNSP);) { pstmtUpdate.setString(1, UUID.randomUUID().toString()); pstmtUpdate.setLong(2, physicalNetworkId); pstmtUpdate.setString(3, "JuniperSRX"); @@ -897,13 +770,6 @@ private void addSrxServiceProvider(Connection conn, long physicalNetworkId, long pstmtUpdate.executeUpdate(); } catch (SQLException e) { throw new CloudRuntimeException("Exception while adding PhysicalNetworkServiceProvider JuniperSRX", e); - } finally { - if (pstmtUpdate != null) { - try { - pstmtUpdate.close(); - } catch (SQLException e) { - } - } } } @@ -1045,15 +911,8 @@ private void fixZoneUsingExternalDevices(Connection conn) { } catch (SQLException e) { throw new CloudRuntimeException("Unable create a mapping for the networks in network_external_lb_device_map and network_external_firewall_device_map", e); } finally { - try { - if (rs != null) { - rs.close(); - } - if (pstmt != null) { - pstmt.close(); - } - } catch (SQLException e) { - } + closeAutoCloseable(rs); + closeAutoCloseable(pstmt); } s_logger.info("Successfully upgraded networks using F5 and SRX devices to have a entry in the network_external_lb_device_map and network_external_firewall_device_map"); } @@ -1062,12 +921,11 @@ private void fixZoneUsingExternalDevices(Connection conn) { private void encryptConfig(Connection conn) { //Encrypt config params and change category to Hidden s_logger.debug("Encrypting Config values"); - PreparedStatement pstmt = null; - ResultSet rs = null; - try { - pstmt = - conn.prepareStatement("select name, value from `cloud`.`configuration` where name in ('router.ram.size', 'secondary.storage.vm', 'security.hash.key') and category <> 'Hidden'"); - rs = pstmt.executeQuery(); + try ( + PreparedStatement pstmt = conn.prepareStatement("select name, value from `cloud`.`configuration` where name in ('router.ram.size', 'secondary.storage.vm', 'security.hash.key') and category <> 'Hidden'"); + PreparedStatement pstmt1 = conn.prepareStatement("update `cloud`.`configuration` set value=?, category = 'Hidden' where name=?"); + ResultSet rs = pstmt.executeQuery(); + ) { while (rs.next()) { String name = rs.getString(1); String value = rs.getString(2); @@ -1075,37 +933,25 @@ private void encryptConfig(Connection conn) { continue; } String encryptedValue = DBEncryptionUtil.encrypt(value); - pstmt = conn.prepareStatement("update `cloud`.`configuration` set value=?, category = 'Hidden' where name=?"); - pstmt.setBytes(1, encryptedValue.getBytes("UTF-8")); - pstmt.setString(2, name); - pstmt.executeUpdate(); + pstmt1.setBytes(1, encryptedValue.getBytes("UTF-8")); + pstmt1.setString(2, name); + pstmt1.executeUpdate(); } } catch (SQLException e) { throw new CloudRuntimeException("Unable encrypt configuration values ", e); } catch (UnsupportedEncodingException e) { throw new CloudRuntimeException("Unable encrypt configuration values ", e); - } finally { - try { - if (rs != null) { - rs.close(); - } - - if (pstmt != null) { - pstmt.close(); - } - } catch (SQLException e) { - } } s_logger.debug("Done encrypting Config values"); } private void encryptClusterDetails(Connection conn) { s_logger.debug("Encrypting cluster details"); - PreparedStatement pstmt = null; - ResultSet rs = null; - try { - pstmt = conn.prepareStatement("select id, value from `cloud`.`cluster_details` where name = 'password'"); - rs = pstmt.executeQuery(); + try ( + PreparedStatement pstmt = conn.prepareStatement("select id, value from `cloud`.`cluster_details` where name = 'password'"); + PreparedStatement pstmt1 = conn.prepareStatement("update `cloud`.`cluster_details` set value=? where id=?"); + ResultSet rs = pstmt.executeQuery(); + ) { while (rs.next()) { long id = rs.getLong(1); String value = rs.getString(2); @@ -1113,26 +959,14 @@ private void encryptClusterDetails(Connection conn) { continue; } String encryptedValue = DBEncryptionUtil.encrypt(value); - pstmt = conn.prepareStatement("update `cloud`.`cluster_details` set value=? where id=?"); - pstmt.setBytes(1, encryptedValue.getBytes("UTF-8")); - pstmt.setLong(2, id); - pstmt.executeUpdate(); + pstmt1.setBytes(1, encryptedValue.getBytes("UTF-8")); + pstmt1.setLong(2, id); + pstmt1.executeUpdate(); } } catch (SQLException e) { throw new CloudRuntimeException("Unable encrypt cluster_details values ", e); } catch (UnsupportedEncodingException e) { throw new CloudRuntimeException("Unable encrypt cluster_details values ", e); - } finally { - try { - if (rs != null) { - rs.close(); - } - - if (pstmt != null) { - pstmt.close(); - } - } catch (SQLException e) { - } } s_logger.debug("Done encrypting cluster_details"); } diff --git a/engine/schema/src/com/cloud/upgrade/dao/Upgrade304to305.java b/engine/schema/src/com/cloud/upgrade/dao/Upgrade304to305.java index 2472716d3fa2..3f1268845c07 100644 --- a/engine/schema/src/com/cloud/upgrade/dao/Upgrade304to305.java +++ b/engine/schema/src/com/cloud/upgrade/dao/Upgrade304to305.java @@ -33,7 +33,7 @@ import com.cloud.utils.exception.CloudRuntimeException; import com.cloud.utils.script.Script; -public class Upgrade304to305 extends Upgrade30xBase implements DbUpgrade { +public class Upgrade304to305 extends Upgrade30xBase { final static Logger s_logger = Logger.getLogger(Upgrade304to305.class); @Override @@ -173,16 +173,8 @@ private void addVpcProvider(Connection conn) { } catch (SQLException e) { throw new CloudRuntimeException("Unable add VPC physical network service provider ", e); } finally { - try { - if (rs != null) { - rs.close(); - } - - if (pstmt != null) { - pstmt.close(); - } - } catch (SQLException e) { - } + closeAutoCloseable(rs); + closeAutoCloseable(pstmt); } s_logger.debug("Done adding VPC physical network service providers to all physical networks"); } @@ -220,16 +212,8 @@ private void updateRouterNetworkRef(Connection conn) { } catch (SQLException e) { throw new CloudRuntimeException("Failed to update the router/network reference ", e); } finally { - try { - if (rs != null) { - rs.close(); - } - - if (pstmt != null) { - pstmt.close(); - } - } catch (SQLException e) { - } + closeAutoCloseable(rs); + closeAutoCloseable(pstmt); } s_logger.debug("Done updating router/network references"); } @@ -254,16 +238,8 @@ private void addHostDetailsUniqueKey(Connection conn) { } catch (SQLException e) { throw new CloudRuntimeException("Failed to check/update the host_details unique key ", e); } finally { - try { - if (rs != null) { - rs.close(); - } - - if (pstmt != null) { - pstmt.close(); - } - } catch (SQLException e) { - } + closeAutoCloseable(rs); + closeAutoCloseable(pstmt); } } @@ -407,15 +383,8 @@ private void fixZoneUsingExternalDevices(Connection conn) { } catch (SQLException e) { throw new CloudRuntimeException("Unable create a mapping for the networks in network_external_lb_device_map and network_external_firewall_device_map", e); } finally { - try { - if (rs != null) { - rs.close(); - } - if (pstmt != null) { - pstmt.close(); - } - } catch (SQLException e) { - } + closeAutoCloseable(rs); + closeAutoCloseable(pstmt); } s_logger.info("Successfully upgraded network using F5 and SRX devices to have a entry in the network_external_lb_device_map and network_external_firewall_device_map"); } @@ -487,16 +456,8 @@ private void encryptClusterDetails(Connection conn) { } catch (UnsupportedEncodingException e) { throw new CloudRuntimeException("Unable encrypt cluster_details values ", e); } finally { - try { - if (rs != null) { - rs.close(); - } - - if (pstmt != null) { - pstmt.close(); - } - } catch (SQLException e) { - } + closeAutoCloseable(rs); + closeAutoCloseable(pstmt); } s_logger.debug("Done encrypting cluster_details"); } diff --git a/engine/schema/src/com/cloud/upgrade/dao/Upgrade305to306.java b/engine/schema/src/com/cloud/upgrade/dao/Upgrade305to306.java index 622f7ea6a543..c31ce659a002 100644 --- a/engine/schema/src/com/cloud/upgrade/dao/Upgrade305to306.java +++ b/engine/schema/src/com/cloud/upgrade/dao/Upgrade305to306.java @@ -31,7 +31,7 @@ import com.cloud.utils.exception.CloudRuntimeException; import com.cloud.utils.script.Script; -public class Upgrade305to306 extends Upgrade30xBase implements DbUpgrade { +public class Upgrade305to306 extends Upgrade30xBase { final static Logger s_logger = Logger.getLogger(Upgrade305to306.class); @Override @@ -82,55 +82,33 @@ private void addIndexForAlert(Connection conn) { DbUpgradeUtils.dropKeysIfExist(conn, "alert", indexList, false); //Now add index. - PreparedStatement pstmt = null; - try { - pstmt = conn.prepareStatement("ALTER TABLE `cloud`.`alert` ADD INDEX `i_alert__last_sent`(`last_sent`)"); + try (PreparedStatement pstmt = conn.prepareStatement("ALTER TABLE `cloud`.`alert` ADD INDEX `i_alert__last_sent`(`last_sent`)");) { pstmt.executeUpdate(); s_logger.debug("Added index i_alert__last_sent for table alert"); } catch (SQLException e) { throw new CloudRuntimeException("Unable to add index i_alert__last_sent to alert table for the column last_sent", e); - } finally { - try { - if (pstmt != null) { - pstmt.close(); - } - } catch (SQLException e) { - } } } private void upgradeEIPNetworkOfferings(Connection conn) { - PreparedStatement pstmt = null; - ResultSet rs = null; - - try { - pstmt = conn.prepareStatement("select id, elastic_ip_service from `cloud`.`network_offerings` where traffic_type='Guest'"); - rs = pstmt.executeQuery(); + try ( + PreparedStatement pstmt = conn.prepareStatement("select id, elastic_ip_service from `cloud`.`network_offerings` where traffic_type='Guest'"); + PreparedStatement pstmt1 = conn.prepareStatement("UPDATE `cloud`.`network_offerings` set eip_associate_public_ip=? where id=?"); + ResultSet rs = pstmt.executeQuery(); + ){ while (rs.next()) { long id = rs.getLong(1); // check if elastic IP service is enabled for network offering if (rs.getLong(2) != 0) { //update network offering with eip_associate_public_ip set to true - pstmt = conn.prepareStatement("UPDATE `cloud`.`network_offerings` set eip_associate_public_ip=? where id=?"); - pstmt.setBoolean(1, true); - pstmt.setLong(2, id); - pstmt.executeUpdate(); + pstmt1.setBoolean(1, true); + pstmt1.setLong(2, id); + pstmt1.executeUpdate(); } } } catch (SQLException e) { throw new CloudRuntimeException("Unable to set eip_associate_public_ip for network offerings with EIP service enabled.", e); - } finally { - try { - if (rs != null) { - rs.close(); - } - - if (pstmt != null) { - pstmt.close(); - } - } catch (SQLException e) { - } } } @@ -143,20 +121,11 @@ private void addIndexForHostDetails(Connection conn) { DbUpgradeUtils.dropKeysIfExist(conn, "host_details", indexList, false); //Now add index. - PreparedStatement pstmt = null; - try { - pstmt = conn.prepareStatement("ALTER TABLE `cloud`.`host_details` ADD INDEX `fk_host_details__host_id`(`host_id`)"); + try (PreparedStatement pstmt = conn.prepareStatement("ALTER TABLE `cloud`.`host_details` ADD INDEX `fk_host_details__host_id`(`host_id`)");) { pstmt.executeUpdate(); s_logger.debug("Added index fk_host_details__host_id for table host_details"); } catch (SQLException e) { throw new CloudRuntimeException("Unable to add index fk_host_details__host_id to host_details table for the column host_id", e); - } finally { - try { - if (pstmt != null) { - pstmt.close(); - } - } catch (SQLException e) { - } } } @@ -218,15 +187,8 @@ private void upgradeEgressFirewallRules(Connection conn) { } catch (SQLException e) { throw new CloudRuntimeException("Unable to set egress firewall rules ", e); } finally { - try { - if (rs != null) { - rs.close(); - } - if (pstmt != null) { - pstmt.close(); - } - } catch (SQLException e) { - } + closeAutoCloseable(rs); + closeAutoCloseable(pstmt); } } @@ -247,16 +209,8 @@ private void removeFirewallServiceFromSharedNetworkOfferingWithSGService(Connect } catch (SQLException e) { throw new CloudRuntimeException("Unable to remove Firewall service for SG shared network offering.", e); } finally { - try { - if (rs != null) { - rs.close(); - } - - if (pstmt != null) { - pstmt.close(); - } - } catch (SQLException e) { - } + closeAutoCloseable(rs); + closeAutoCloseable(pstmt); } } @@ -288,16 +242,8 @@ private void fix22xKVMSnapshots(Connection conn) { } catch (SQLException e) { throw new CloudRuntimeException("Unable to update backup id for KVM snapshots", e); } finally { - try { - if (rs != null) { - rs.close(); - } - - if (pstmt != null) { - pstmt.close(); - } - } catch (SQLException e) { - } + closeAutoCloseable(rs); + closeAutoCloseable(pstmt); } } diff --git a/engine/schema/src/com/cloud/upgrade/dao/Upgrade306to307.java b/engine/schema/src/com/cloud/upgrade/dao/Upgrade306to307.java index ab96b58358f3..28652189726e 100644 --- a/engine/schema/src/com/cloud/upgrade/dao/Upgrade306to307.java +++ b/engine/schema/src/com/cloud/upgrade/dao/Upgrade306to307.java @@ -98,19 +98,9 @@ protected void updateConcurrentConnectionsInNetworkOfferings(Connection conn) { pstmt.executeUpdate(); } catch (SQLException e) { } finally { - try { - if (rs != null) { - rs.close(); - } - - if (rs1 != null) { - rs1.close(); - } - if (pstmt != null) { - pstmt.close(); - } - } catch (SQLException e) { - } + closeAutoCloseable(rs); + closeAutoCloseable(rs1); + closeAutoCloseable(pstmt); } } diff --git a/engine/schema/src/com/cloud/upgrade/dao/Upgrade307to410.java b/engine/schema/src/com/cloud/upgrade/dao/Upgrade307to410.java index 243513ae0ea3..4319481fe938 100644 --- a/engine/schema/src/com/cloud/upgrade/dao/Upgrade307to410.java +++ b/engine/schema/src/com/cloud/upgrade/dao/Upgrade307to410.java @@ -69,23 +69,14 @@ private void updateRegionEntries(Connection conn) { if (regionId != null) { region_id = Integer.parseInt(regionId); } - PreparedStatement pstmt = null; - try { + try (PreparedStatement pstmt = conn.prepareStatement("update `cloud`.`region` set id = ?");){ //Update regionId in region table s_logger.debug("Updating region table with Id: " + region_id); - pstmt = conn.prepareStatement("update `cloud`.`region` set id = ?"); pstmt.setInt(1, region_id); pstmt.executeUpdate(); } catch (SQLException e) { throw new CloudRuntimeException("Error while updating region entries", e); - } finally { - try { - if (pstmt != null) { - pstmt.close(); - } - } catch (SQLException e) { - } } } diff --git a/engine/schema/src/com/cloud/upgrade/dao/Upgrade30xBase.java b/engine/schema/src/com/cloud/upgrade/dao/Upgrade30xBase.java index aacede083fad..5a370f00fe06 100644 --- a/engine/schema/src/com/cloud/upgrade/dao/Upgrade30xBase.java +++ b/engine/schema/src/com/cloud/upgrade/dao/Upgrade30xBase.java @@ -27,7 +27,7 @@ import com.cloud.utils.exception.CloudRuntimeException; -public abstract class Upgrade30xBase implements DbUpgrade { +public abstract class Upgrade30xBase extends LegacyDbUpgrade implements DbUpgrade { final static Logger s_logger = Logger.getLogger(Upgrade30xBase.class); @@ -46,18 +46,8 @@ protected String getNetworkLabelFromConfig(Connection conn, String name) { } catch (SQLException e) { throw new CloudRuntimeException("Unable to fetch network label from configuration", e); } finally { - if (rs != null) { - try { - rs.close(); - } catch (SQLException e) { - } - } - if (pstmt != null) { - try { - pstmt.close(); - } catch (SQLException e) { - } - } + closeAutoCloseable(rs); + closeAutoCloseable(pstmt); } return networkLabel; } @@ -117,19 +107,8 @@ protected long addPhysicalNetworkToZone(Connection conn, long zoneId, String zon } catch (SQLException e) { throw new CloudRuntimeException("Exception while adding PhysicalNetworks", e); } finally { - if (pstmtUpdate != null) { - try { - pstmtUpdate.close(); - } catch (SQLException e) { - } - } - if (pstmt2 != null) { - try { - pstmt2.close(); - } catch (SQLException e) { - } - } - + closeAutoCloseable(pstmt2); + closeAutoCloseable(pstmtUpdate); } } @@ -152,12 +131,7 @@ protected void addTrafficType(Connection conn, long physicalNetworkId, String tr } catch (SQLException e) { throw new CloudRuntimeException("Exception while adding PhysicalNetworks", e); } finally { - if (pstmtUpdate != null) { - try { - pstmtUpdate.close(); - } catch (SQLException e) { - } - } + closeAutoCloseable(pstmtUpdate); } } @@ -204,18 +178,8 @@ protected void addDefaultSGProvider(Connection conn, long physicalNetworkId, lon } catch (SQLException e) { throw new CloudRuntimeException("Exception while adding default Security Group Provider", e); } finally { - if (pstmtUpdate != null) { - try { - pstmtUpdate.close(); - } catch (SQLException e) { - } - } - if (pstmt2 != null) { - try { - pstmt2.close(); - } catch (SQLException e) { - } - } + closeAutoCloseable(pstmt2); + closeAutoCloseable(pstmtUpdate); } } @@ -261,18 +225,8 @@ protected void addDefaultVRProvider(Connection conn, long physicalNetworkId, lon } catch (SQLException e) { throw new CloudRuntimeException("Exception while adding PhysicalNetworks", e); } finally { - if (pstmtUpdate != null) { - try { - pstmtUpdate.close(); - } catch (SQLException e) { - } - } - if (pstmt2 != null) { - try { - pstmt2.close(); - } catch (SQLException e) { - } - } + closeAutoCloseable(pstmt2); + closeAutoCloseable(pstmtUpdate); } } @@ -299,12 +253,7 @@ protected void addPhysicalNtwk_To_Ntwk_IP_Vlan(Connection conn, long physicalNet } catch (SQLException e) { throw new CloudRuntimeException("Exception while adding PhysicalNetworks", e); } finally { - if (pstmtUpdate != null) { - try { - pstmtUpdate.close(); - } catch (SQLException e) { - } - } + closeAutoCloseable(pstmtUpdate); } } From 39bf1fed6867c4de673575b8b0925337015088ee Mon Sep 17 00:00:00 2001 From: Daan Hoogland Date: Sun, 2 Aug 2015 19:48:58 +0200 Subject: [PATCH 06/12] CLOUDSTACK-8656: try with resource te eliminate empty catch clauses --- .../image/db/SnapshotDataStoreDaoImpl.java | 72 +++++++------------ 1 file changed, 27 insertions(+), 45 deletions(-) diff --git a/engine/storage/src/org/apache/cloudstack/storage/image/db/SnapshotDataStoreDaoImpl.java b/engine/storage/src/org/apache/cloudstack/storage/image/db/SnapshotDataStoreDaoImpl.java index ea73ecd7e339..142cd669cb33 100644 --- a/engine/storage/src/org/apache/cloudstack/storage/image/db/SnapshotDataStoreDaoImpl.java +++ b/engine/storage/src/org/apache/cloudstack/storage/image/db/SnapshotDataStoreDaoImpl.java @@ -221,26 +221,20 @@ public SnapshotDataStoreVO findByStoreSnapshot(DataStoreRole role, long storeId, @Override public SnapshotDataStoreVO findLatestSnapshotForVolume(Long volumeId, DataStoreRole role) { TransactionLegacy txn = TransactionLegacy.currentTxn(); - PreparedStatement pstmt = null; - ResultSet rs = null; - try { - pstmt = txn.prepareStatement(findLatestSnapshot); + try ( + PreparedStatement pstmt = txn.prepareStatement(findLatestSnapshot); + ){ pstmt.setString(1, role.toString()); pstmt.setLong(2, volumeId); - rs = pstmt.executeQuery(); - while (rs.next()) { - long sid = rs.getLong(1); - long snid = rs.getLong(3); - return findByStoreSnapshot(role, sid, snid); + try (ResultSet rs = pstmt.executeQuery();) { + while (rs.next()) { + long sid = rs.getLong(1); + long snid = rs.getLong(3); + return findByStoreSnapshot(role, sid, snid); + } } } catch (SQLException e) { s_logger.debug("Failed to find latest snapshot for volume: " + volumeId + " due to: " + e.toString()); - } finally { - try { - if (pstmt != null) - pstmt.close(); - } catch (SQLException e) { - } } return null; } @@ -248,26 +242,20 @@ public SnapshotDataStoreVO findLatestSnapshotForVolume(Long volumeId, DataStoreR @Override public SnapshotDataStoreVO findOldestSnapshotForVolume(Long volumeId, DataStoreRole role) { TransactionLegacy txn = TransactionLegacy.currentTxn(); - PreparedStatement pstmt = null; - ResultSet rs = null; - try { - pstmt = txn.prepareStatement(findOldestSnapshot); + try ( + PreparedStatement pstmt = txn.prepareStatement(findOldestSnapshot); + ){ pstmt.setString(1, role.toString()); pstmt.setLong(2, volumeId); - rs = pstmt.executeQuery(); - while (rs.next()) { - long sid = rs.getLong(1); - long snid = rs.getLong(3); - return findByStoreSnapshot(role, sid, snid); + try (ResultSet rs = pstmt.executeQuery();) { + while (rs.next()) { + long sid = rs.getLong(1); + long snid = rs.getLong(3); + return findByStoreSnapshot(role, sid, snid); + } } } catch (SQLException e) { s_logger.debug("Failed to find oldest snapshot for volume: " + volumeId + " due to: " + e.toString()); - } finally { - try { - if (pstmt != null) - pstmt.close(); - } catch (SQLException e) { - } } return null; } @@ -276,27 +264,21 @@ public SnapshotDataStoreVO findOldestSnapshotForVolume(Long volumeId, DataStoreR @DB public SnapshotDataStoreVO findParent(DataStoreRole role, Long storeId, Long volumeId) { TransactionLegacy txn = TransactionLegacy.currentTxn(); - PreparedStatement pstmt = null; - ResultSet rs = null; - try { - pstmt = txn.prepareStatement(parentSearch); + try ( + PreparedStatement pstmt = txn.prepareStatement(parentSearch); + ){ pstmt.setLong(1, storeId); pstmt.setString(2, role.toString()); pstmt.setLong(3, volumeId); - rs = pstmt.executeQuery(); - while (rs.next()) { - long sid = rs.getLong(1); - long snid = rs.getLong(3); - return findByStoreSnapshot(role, sid, snid); + try (ResultSet rs = pstmt.executeQuery();) { + while (rs.next()) { + long sid = rs.getLong(1); + long snid = rs.getLong(3); + return findByStoreSnapshot(role, sid, snid); + } } } catch (SQLException e) { s_logger.debug("Failed to find parent snapshot: " + e.toString()); - } finally { - try { - if (pstmt != null) - pstmt.close(); - } catch (SQLException e) { - } } return null; } From 16330e92daa30c6f0b75dd2aa3d3c7674a6ae8a5 Mon Sep 17 00:00:00 2001 From: Daan Hoogland Date: Sun, 2 Aug 2015 19:55:14 +0200 Subject: [PATCH 07/12] CLOUDSTACK-8656: silent close failure of clustering socket log as info --- .../src/com/cloud/cluster/ClusterServiceServletContainer.java | 1 + 1 file changed, 1 insertion(+) diff --git a/framework/cluster/src/com/cloud/cluster/ClusterServiceServletContainer.java b/framework/cluster/src/com/cloud/cluster/ClusterServiceServletContainer.java index f5d67224d2bd..08f5dba69f69 100644 --- a/framework/cluster/src/com/cloud/cluster/ClusterServiceServletContainer.java +++ b/framework/cluster/src/com/cloud/cluster/ClusterServiceServletContainer.java @@ -114,6 +114,7 @@ public void stopRunning() { try { _serverSocket.close(); } catch (IOException e) { + s_logger.info("[ignored] error on closing server socket", e); } _serverSocket = null; } From 8e3b99d0d6c7d76c1895fa7bbcf89671acef84a0 Mon Sep 17 00:00:00 2001 From: Daan Hoogland Date: Mon, 3 Aug 2015 11:54:35 +0200 Subject: [PATCH 08/12] CLOUDSTACK-8656: removed redundant implements --- engine/schema/src/com/cloud/upgrade/dao/Upgrade30xBase.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engine/schema/src/com/cloud/upgrade/dao/Upgrade30xBase.java b/engine/schema/src/com/cloud/upgrade/dao/Upgrade30xBase.java index 5a370f00fe06..2ca562aca204 100644 --- a/engine/schema/src/com/cloud/upgrade/dao/Upgrade30xBase.java +++ b/engine/schema/src/com/cloud/upgrade/dao/Upgrade30xBase.java @@ -27,7 +27,7 @@ import com.cloud.utils.exception.CloudRuntimeException; -public abstract class Upgrade30xBase extends LegacyDbUpgrade implements DbUpgrade { +public abstract class Upgrade30xBase extends LegacyDbUpgrade { final static Logger s_logger = Logger.getLogger(Upgrade30xBase.class); From f221b9a4239dcd27556907e2dd4418d79ec71189 Mon Sep 17 00:00:00 2001 From: Daan Hoogland Date: Mon, 3 Aug 2015 19:35:41 +0200 Subject: [PATCH 09/12] CLOUDSTACK-8656: 30x legacy upgrade code exception messages --- .../cloud/upgrade/dao/Upgrade306to307.java | 3 ++- .../com/cloud/upgrade/dao/Upgrade30to301.java | 19 ++++--------------- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/engine/schema/src/com/cloud/upgrade/dao/Upgrade306to307.java b/engine/schema/src/com/cloud/upgrade/dao/Upgrade306to307.java index 28652189726e..a911882fa69f 100644 --- a/engine/schema/src/com/cloud/upgrade/dao/Upgrade306to307.java +++ b/engine/schema/src/com/cloud/upgrade/dao/Upgrade306to307.java @@ -28,7 +28,7 @@ import com.cloud.utils.exception.CloudRuntimeException; import com.cloud.utils.script.Script; -public class Upgrade306to307 extends Upgrade30xBase implements DbUpgrade { +public class Upgrade306to307 extends Upgrade30xBase { final static Logger s_logger = Logger.getLogger(Upgrade306to307.class); @Override @@ -97,6 +97,7 @@ protected void updateConcurrentConnectionsInNetworkOfferings(Connection conn) { pstmt = conn.prepareStatement("drop table `cloud`.`network_details`"); pstmt.executeUpdate(); } catch (SQLException e) { + s_logger.info("[ignored] error during network offering update:" + e.getLocalizedMessage(), e); } finally { closeAutoCloseable(rs); closeAutoCloseable(rs1); diff --git a/engine/schema/src/com/cloud/upgrade/dao/Upgrade30to301.java b/engine/schema/src/com/cloud/upgrade/dao/Upgrade30to301.java index 65712d0841bd..fafec269c51c 100644 --- a/engine/schema/src/com/cloud/upgrade/dao/Upgrade30to301.java +++ b/engine/schema/src/com/cloud/upgrade/dao/Upgrade30to301.java @@ -28,7 +28,7 @@ import com.cloud.utils.exception.CloudRuntimeException; import com.cloud.utils.script.Script; -public class Upgrade30to301 implements DbUpgrade { +public class Upgrade30to301 extends LegacyDbUpgrade { final static Logger s_logger = Logger.getLogger(Upgrade30to301.class); @Override @@ -100,20 +100,9 @@ protected void udpateAccountNetworkResourceCount(Connection conn) { } catch (SQLException e) { throw new CloudRuntimeException("Unable to update network resource count for account id=" + accountId, e); } finally { - try { - if (rs != null) { - rs.close(); - } - - if (rs1 != null) { - rs1.close(); - } - - if (pstmt != null) { - pstmt.close(); - } - } catch (SQLException e) { - } + closeAutoCloseable(rs); + closeAutoCloseable(rs1); + closeAutoCloseable(pstmt); } } From 87ae15015912efdc20ce3e6deea7ff4f4e54021f Mon Sep 17 00:00:00 2001 From: Daan Hoogland Date: Mon, 3 Aug 2015 19:42:47 +0200 Subject: [PATCH 10/12] CLOUDSTACK-8656: replace empty catch block on close by try-with-resource --- .../config/dao/ConfigurationDaoImpl.java | 22 +++---------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/framework/config/src/org/apache/cloudstack/framework/config/dao/ConfigurationDaoImpl.java b/framework/config/src/org/apache/cloudstack/framework/config/dao/ConfigurationDaoImpl.java index f3f049526666..f9c2433754bc 100644 --- a/framework/config/src/org/apache/cloudstack/framework/config/dao/ConfigurationDaoImpl.java +++ b/framework/config/src/org/apache/cloudstack/framework/config/dao/ConfigurationDaoImpl.java @@ -144,21 +144,13 @@ public void init() throws ConfigurationException { @Deprecated public boolean update(String name, String value) { TransactionLegacy txn = TransactionLegacy.currentTxn(); - PreparedStatement stmt = null; - try { - stmt = txn.prepareStatement(UPDATE_CONFIGURATION_SQL); + try (PreparedStatement stmt = txn.prepareStatement(UPDATE_CONFIGURATION_SQL);){ stmt.setString(1, value); stmt.setString(2, name); stmt.executeUpdate(); return true; } catch (Exception e) { s_logger.warn("Unable to update Configuration Value", e); - } finally { - try { - if (stmt != null) - stmt.close(); - } catch (SQLException e) { - } } return false; } @@ -166,22 +158,14 @@ public boolean update(String name, String value) { @Override public boolean update(String name, String category, String value) { TransactionLegacy txn = TransactionLegacy.currentTxn(); - PreparedStatement stmt = null; - try { - value = ("Hidden".equals(category) || "Secure".equals(category)) ? DBEncryptionUtil.encrypt(value) : value; - stmt = txn.prepareStatement(UPDATE_CONFIGURATION_SQL); + value = ("Hidden".equals(category) || "Secure".equals(category)) ? DBEncryptionUtil.encrypt(value) : value; + try (PreparedStatement stmt = txn.prepareStatement(UPDATE_CONFIGURATION_SQL);) { stmt.setString(1, value); stmt.setString(2, name); stmt.executeUpdate(); return true; } catch (Exception e) { s_logger.warn("Unable to update Configuration Value", e); - } finally { - try { - if (stmt != null) - stmt.close(); - } catch (SQLException e) { - } } return false; } From 1f460f41740577f9d3a52aac92da07fa07acd5a7 Mon Sep 17 00:00:00 2001 From: Daan Hoogland Date: Mon, 3 Aug 2015 20:11:18 +0200 Subject: [PATCH 11/12] CLOUDSTACK-8656: messages on SQL exception in DbUtils! --- .../config/dao/ConfigurationDaoImpl.java | 14 ++-- .../db/src/com/cloud/utils/db/DbUtil.java | 70 ++++++------------- 2 files changed, 28 insertions(+), 56 deletions(-) diff --git a/framework/config/src/org/apache/cloudstack/framework/config/dao/ConfigurationDaoImpl.java b/framework/config/src/org/apache/cloudstack/framework/config/dao/ConfigurationDaoImpl.java index f9c2433754bc..afc20e181a56 100644 --- a/framework/config/src/org/apache/cloudstack/framework/config/dao/ConfigurationDaoImpl.java +++ b/framework/config/src/org/apache/cloudstack/framework/config/dao/ConfigurationDaoImpl.java @@ -158,12 +158,14 @@ public boolean update(String name, String value) { @Override public boolean update(String name, String category, String value) { TransactionLegacy txn = TransactionLegacy.currentTxn(); - value = ("Hidden".equals(category) || "Secure".equals(category)) ? DBEncryptionUtil.encrypt(value) : value; - try (PreparedStatement stmt = txn.prepareStatement(UPDATE_CONFIGURATION_SQL);) { - stmt.setString(1, value); - stmt.setString(2, name); - stmt.executeUpdate(); - return true; + try { + value = ("Hidden".equals(category) || "Secure".equals(category)) ? DBEncryptionUtil.encrypt(value) : value; + try (PreparedStatement stmt = txn.prepareStatement(UPDATE_CONFIGURATION_SQL);) { + stmt.setString(1, value); + stmt.setString(2, name); + stmt.executeUpdate(); + return true; + } } catch (Exception e) { s_logger.warn("Unable to update Configuration Value", e); } diff --git a/framework/db/src/com/cloud/utils/db/DbUtil.java b/framework/db/src/com/cloud/utils/db/DbUtil.java index 43ed46272cab..d8689050c636 100644 --- a/framework/db/src/com/cloud/utils/db/DbUtil.java +++ b/framework/db/src/com/cloud/utils/db/DbUtil.java @@ -61,10 +61,7 @@ public static Connection getConnectionForGlobalLocks(String name, boolean forLoc try { connection.setAutoCommit(true); } catch (SQLException e) { - try { - connection.close(); - } catch (SQLException sqlException) { - } + closeAutoCloseable(connection, "error closing connection for global locks"); return null; } s_connectionForGlobalLocks.put(name, connection); @@ -203,37 +200,28 @@ public static boolean getGlobalLock(String name, int timeoutSeconds) { return false; } - PreparedStatement pstmt = null; - ResultSet rs = null; - try { - pstmt = conn.prepareStatement("SELECT COALESCE(GET_LOCK(?, ?),0)"); - + try (PreparedStatement pstmt = conn.prepareStatement("SELECT COALESCE(GET_LOCK(?, ?),0)");) { pstmt.setString(1, name); pstmt.setInt(2, timeoutSeconds); - rs = pstmt.executeQuery(); - if (rs != null && rs.first()) { - if (rs.getInt(1) > 0) { - return true; - } else { - if (s_logger.isDebugEnabled()) - s_logger.debug("GET_LOCK() timed out on lock : " + name); + try (ResultSet rs = pstmt.executeQuery();) { + if (rs != null && rs.first()) { + if (rs.getInt(1) > 0) { + return true; + } else { + if (s_logger.isDebugEnabled()) + s_logger.debug("GET_LOCK() timed out on lock : " + name); + } } } } catch (SQLException e) { s_logger.error("GET_LOCK() throws exception ", e); } catch (Throwable e) { s_logger.error("GET_LOCK() throws exception ", e); - } finally { - closeStatement(pstmt); - closeResultSet(rs); } removeConnectionForGlobalLocks(name); - try { - conn.close(); - } catch (SQLException e) { - } + closeAutoCloseable(conn, "connection for global lock"); return false; } @@ -285,45 +273,27 @@ public static void closeResources(final Statement statement, final ResultSet res } public static void closeResultSet(final ResultSet resultSet) { - - try { - - if (resultSet != null) { - resultSet.close(); - } - - } catch (SQLException e) { - s_logger.warn("Ignored exception while closing result set.", e); - } - + closeAutoCloseable(resultSet, "exception while closing result set."); } public static void closeStatement(final Statement statement) { - - try { - - if (statement != null) { - statement.close(); - } - - } catch (SQLException e) { - s_logger.warn("Ignored exception while closing statement.", e); - } - + closeAutoCloseable(statement, "exception while closing statement."); } public static void closeConnection(final Connection connection) { + closeAutoCloseable(connection, "exception while close connection."); + } + public static void closeAutoCloseable(AutoCloseable ac, String message) { try { - if (connection != null) { - connection.close(); + if (ac != null) { + ac.close(); } - } catch (SQLException e) { - s_logger.warn("Ignored exception while close connection.", e); + } catch (Exception e) { + s_logger.warn("[ignored] " + message, e); } - } } From 75093dcd8fbac3defb2fa22df6e4269a0ec18ff1 Mon Sep 17 00:00:00 2001 From: Daan Hoogland Date: Mon, 3 Aug 2015 21:10:11 +0200 Subject: [PATCH 12/12] CLOUDSTACK-8656: checkstyle no longer used import removed --- .../cloudstack/framework/config/dao/ConfigurationDaoImpl.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/framework/config/src/org/apache/cloudstack/framework/config/dao/ConfigurationDaoImpl.java b/framework/config/src/org/apache/cloudstack/framework/config/dao/ConfigurationDaoImpl.java index afc20e181a56..65bad9c44a74 100644 --- a/framework/config/src/org/apache/cloudstack/framework/config/dao/ConfigurationDaoImpl.java +++ b/framework/config/src/org/apache/cloudstack/framework/config/dao/ConfigurationDaoImpl.java @@ -17,7 +17,6 @@ package org.apache.cloudstack.framework.config.dao; import java.sql.PreparedStatement; -import java.sql.SQLException; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -26,11 +25,10 @@ import javax.ejb.Local; import javax.naming.ConfigurationException; +import org.apache.cloudstack.framework.config.impl.ConfigurationVO; import org.apache.log4j.Logger; import org.springframework.stereotype.Component; -import org.apache.cloudstack.framework.config.impl.ConfigurationVO; - import com.cloud.utils.component.ComponentLifecycle; import com.cloud.utils.crypt.DBEncryptionUtil; import com.cloud.utils.db.DB;