diff options
author | Gary Wu <gary.i.wu@huawei.com> | 2017-04-11 11:43:21 -0700 |
---|---|---|
committer | Gary Wu <gary.i.wu@huawei.com> | 2017-04-11 11:49:51 -0700 |
commit | 7ee20399328e30044ebad93f2e561934b7811e51 (patch) | |
tree | d1afc27b4b579c2826ff4b1dd145ada81f48d2c8 /adapters/mso-catalog-db-adapter/src/main | |
parent | b6b7bef8bdcad15af01ac88a038dd763ce59f68f (diff) |
Fix resources leaks: CatalogDatabase
Change-Id: I3274dc7a64637cd7cf18d705258c0fc4985171ee
Signed-off-by: Gary Wu <gary.i.wu@huawei.com>
Diffstat (limited to 'adapters/mso-catalog-db-adapter/src/main')
-rw-r--r-- | adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/CatalogDbAdapterRest.java (renamed from adapters/mso-catalog-db-adapter/src/main/java/org.openecomp.mso/adapters/catalogdb/CatalogDbAdapterRest.java) | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org.openecomp.mso/adapters/catalogdb/CatalogDbAdapterRest.java b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/CatalogDbAdapterRest.java index 729aaa0f9a..210e5e7074 100644 --- a/adapters/mso-catalog-db-adapter/src/main/java/org.openecomp.mso/adapters/catalogdb/CatalogDbAdapterRest.java +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/CatalogDbAdapterRest.java @@ -124,37 +124,37 @@ public class CatalogDbAdapterRest { String uuid = ""; List<VnfResource> ret; - try { + try (CatalogDatabase db = new CatalogDatabase()) { if (vnfUuid != null && !vnfUuid.equals("")) { uuid = vnfUuid; LOGGER.debug ("Query serviceVnfs getAllVnfsByVnfModelCustomizationUuid vnfModelCustomizationUuid: " + uuid); - ret = (new CatalogDatabase ()).getAllVnfsByVnfModelCustomizationUuid(uuid); + ret = db.getAllVnfsByVnfModelCustomizationUuid(uuid); } else if (smUuid != null && !smUuid.equals("")) { uuid = smUuid; LOGGER.debug ("Query serviceVnfs getAllVnfsByServiceModelUuid serviceModelUuid: " + uuid); - ret = (new CatalogDatabase ()).getAllVnfsByServiceModelUuid(uuid); + ret = db.getAllVnfsByServiceModelUuid(uuid); } else if (smiUuid != null && !smiUuid.equals("")) { uuid = smiUuid; if (smVer != null && !smVer.equals("")) { LOGGER.debug ("Query serviceVnfs getAllNetworksByServiceModelInvariantUuid serviceModelInvariantUuid: " + uuid+ " serviceModelVersion: "+ smVer); - ret = (new CatalogDatabase ()).getAllVnfsByServiceModelInvariantUuid(uuid, smVer); + ret = db.getAllVnfsByServiceModelInvariantUuid(uuid, smVer); } else { LOGGER.debug ("Query serviceVnfs getAllNetworksByServiceModelInvariantUuid serviceModelUuid: " + uuid); - ret = (new CatalogDatabase ()).getAllVnfsByServiceModelInvariantUuid(uuid); + ret = db.getAllVnfsByServiceModelInvariantUuid(uuid); } } else if (smName != null && !smName.equals("")) { if (smVer != null && !smVer.equals("")) { LOGGER.debug ("Query serviceVnfs getAllVnfsByServiceName serviceModelInvariantName: " + smName+ " serviceModelVersion: "+ smVer); - ret = (new CatalogDatabase ()).getAllVnfsByServiceName(smName, smVer); + ret = db.getAllVnfsByServiceName(smName, smVer); } else { LOGGER.debug ("Query serviceVnfs getAllVnfsByServiceName serviceModelName: " + smName); - ret = (new CatalogDatabase ()).getAllVnfsByServiceName(smName); + ret = db.getAllVnfsByServiceName(smName); } } else { @@ -203,31 +203,31 @@ public class CatalogDbAdapterRest { String uuid = ""; List<NetworkResourceCustomization> ret; - try { + try (CatalogDatabase db = new CatalogDatabase()) { if (nUuid != null && !nUuid.equals("")) { uuid = nUuid; LOGGER.debug ("Query serviceNetworks getAllNetworksByNetworkModelCustomizationUuid networkModelCustomizationUuid: " + uuid); - ret = (new CatalogDatabase ()).getAllNetworksByNetworkModelCustomizationUuid(uuid); + ret = db.getAllNetworksByNetworkModelCustomizationUuid(uuid); } else if (smUuid != null && !smUuid.equals("")) { uuid = smUuid; LOGGER.debug ("Query serviceNetworks getAllNetworksByServiceModelUuid serviceModelUuid: " + uuid); - ret = (new CatalogDatabase ()).getAllNetworksByServiceModelUuid(uuid); + ret = db.getAllNetworksByServiceModelUuid(uuid); } else if (nType != null && !nType.equals("")) { uuid = nType; LOGGER.debug ("Query serviceNetworks getAllNetworksByNetworkType serviceModelUuid: " + uuid); - ret = (new CatalogDatabase ()).getAllNetworksByNetworkType(uuid); + ret = db.getAllNetworksByNetworkType(uuid); } else if (smiUuid != null && !smiUuid.equals("")) { uuid = smiUuid; if (smVer != null && !smVer.equals("")) { LOGGER.debug ("Query serviceNetworks getAllNetworksByServiceModelInvariantUuid serviceModelInvariantUuid: " + uuid+ " serviceModelVersion: "+ smVer); - ret = (new CatalogDatabase ()).getAllNetworksByServiceModelInvariantUuid(uuid, smVer); + ret = db.getAllNetworksByServiceModelInvariantUuid(uuid, smVer); } else { LOGGER.debug ("Query serviceNetworks getAllNetworksByServiceModelInvariantUuid serviceModelUuid: " + uuid); - ret = (new CatalogDatabase ()).getAllNetworksByServiceModelInvariantUuid(uuid); + ret = db.getAllNetworksByServiceModelInvariantUuid(uuid); } } else { @@ -274,22 +274,22 @@ public class CatalogDbAdapterRest { String uuid = ""; ServiceMacroHolder ret; - try { + try (CatalogDatabase db = new CatalogDatabase()) { if (smUuid != null && !smUuid.equals("")) { uuid = smUuid; LOGGER.debug ("Query serviceMacroHolder getAllResourcesByServiceModelUuid serviceModelUuid: " + uuid); - ret = (new CatalogDatabase ()).getAllResourcesByServiceModelUuid(uuid); + ret = db.getAllResourcesByServiceModelUuid(uuid); } else if (smiUuid != null && !smiUuid.equals("")) { uuid = smiUuid; if (smVer != null && !smVer.equals("")) { LOGGER.debug ("Query serviceMacroHolder getAllResourcesByServiceModelInvariantUuid serviceModelInvariantUuid: " + uuid+ " serviceModelVersion: "+ smVer); - ret = (new CatalogDatabase ()).getAllResourcesByServiceModelInvariantUuid(uuid, smVer); + ret = db.getAllResourcesByServiceModelInvariantUuid(uuid, smVer); } else { LOGGER.debug ("Query serviceMacroHolder getAllResourcesByServiceModelInvariantUuid serviceModelUuid: " + uuid); - ret = (new CatalogDatabase ()).getAllResourcesByServiceModelInvariantUuid(uuid); + ret = db.getAllResourcesByServiceModelInvariantUuid(uuid); } } else { @@ -337,28 +337,28 @@ public class CatalogDbAdapterRest { String uuid = ""; List<AllottedResourceCustomization > ret; - try { + try (CatalogDatabase db = new CatalogDatabase()) { if (smUuid != null && !smUuid.equals("")) { uuid = smUuid; LOGGER.debug ("Query AllottedResourceCustomization getAllAllottedResourcesByServiceModelUuid serviceModelUuid: " + uuid); - ret = (new CatalogDatabase ()).getAllAllottedResourcesByServiceModelUuid(uuid); + ret = db.getAllAllottedResourcesByServiceModelUuid(uuid); } else if (smiUuid != null && !smiUuid.equals("")) { uuid = smiUuid; if (smVer != null && !smVer.equals("")) { LOGGER.debug ("Query AllottedResourceCustomization getAllAllottedResourcesByServiceModelInvariantUuid serviceModelInvariantUuid: " + uuid+ " serviceModelVersion: "+ smVer); - ret = (new CatalogDatabase ()).getAllAllottedResourcesByServiceModelInvariantUuid(uuid, smVer); + ret = db.getAllAllottedResourcesByServiceModelInvariantUuid(uuid, smVer); } else { LOGGER.debug ("Query AllottedResourceCustomization getAllAllottedResourcesByServiceModelInvariantUuid serviceModelUuid: " + uuid); - ret = (new CatalogDatabase ()).getAllAllottedResourcesByServiceModelInvariantUuid(uuid); + ret = db.getAllAllottedResourcesByServiceModelInvariantUuid(uuid); } } else if (aUuid != null && !aUuid.equals("")) { uuid = aUuid; LOGGER.debug ("Query AllottedResourceCustomization getAllAllottedResourcesByArModelCustomizationUuid serviceModelUuid: " + uuid); - ret = (new CatalogDatabase ()).getAllAllottedResourcesByArModelCustomizationUuid(uuid); + ret = db.getAllAllottedResourcesByArModelCustomizationUuid(uuid); } else { throw(new Exception("no matching parameters")); |