diff options
author | 2020-06-22 11:15:43 -0400 | |
---|---|---|
committer | 2020-06-22 11:15:43 -0400 | |
commit | 02f5d9e2c02c0b9fffdc494a9b7c87e0a4f7e000 (patch) | |
tree | 957a235369a65f87407f2dc59c78a2fdd10e8f41 /src/main | |
parent | a03865f2807e4aa0c80fbab1be812da2d8466d29 (diff) |
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 <chris.andre@yoppworks.com>
Change-Id: Ib26db5f100d700c2e18d7aa2e5376dbe17f7f846
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/org/onap/aai/cacher/common/MongoConfig.java | 7 |
1 files changed, 3 insertions, 4 deletions
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"); |