From 02f5d9e2c02c0b9fffdc494a9b7c87e0a4f7e000 Mon Sep 17 00:00:00 2001 From: Chris AndreĢ Date: Mon, 22 Jun 2020 11:15:43 -0400 Subject: MongoConfig - Removed Sonar warnings - updated pom.xml files to get rid of warnings - used `try-with-resource` to automatically close variable `mongoC` Issue-ID: AAI-2954 Signed-off-by: Chris Andre Change-Id: Ib26db5f100d700c2e18d7aa2e5376dbe17f7f846 --- src/main/java/org/onap/aai/cacher/common/MongoConfig.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/org/onap/aai/cacher/common/MongoConfig.java b/src/main/java/org/onap/aai/cacher/common/MongoConfig.java index 5c1a541..ca063a7 100644 --- a/src/main/java/org/onap/aai/cacher/common/MongoConfig.java +++ b/src/main/java/org/onap/aai/cacher/common/MongoConfig.java @@ -48,7 +48,7 @@ import java.io.IOException; @Configuration public class MongoConfig { - private final static EELFLogger EELF_LOGGER = EELFManager.getInstance().getLogger(MongoConfig.class); + private static final EELFLogger EELF_LOGGER = EELFManager.getInstance().getLogger(MongoConfig.class); @Value("${mongodb.host}") private String MONGO_DB_HOST; @@ -61,9 +61,8 @@ public class MongoConfig { @Bean public MongoClient mongoClient(MongodProcess mongodProcess) { - try { - // To connect to mongodb server - MongoClient mongoC = new MongoClient(MONGO_DB_HOST, MONGO_DB_PORT); + // To connect to mongodb server + try (MongoClient mongoC = new MongoClient(MONGO_DB_HOST, MONGO_DB_PORT)) { // Now connect to your databases EELF_LOGGER.info("Connect to database successfully"); -- cgit 1.2.3-korg