Merge "Handled unclosed resources using try-with-resources statement"
authorThomas Nelson <nelson24@att.com>
Tue, 23 Jul 2019 16:10:10 +0000 (16:10 +0000)
committerGerrit Code Review <gerrit@onap.org>
Tue, 23 Jul 2019 16:10:10 +0000 (16:10 +0000)
src/main/java/org/onap/music/main/CipherUtil.java

index 0d5b771..5333323 100644 (file)
@@ -1,9 +1,11 @@
 /*
  * ============LICENSE_START==========================================
- * org.onap.music
+ *  org.onap.music
  * ===================================================================
  *  Copyright (c) 2017 AT&T Intellectual Property
  * ===================================================================
+ *  Modification Copyright (c) 2019 IBM
+ * ===================================================================
  *  Licensed 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
@@ -245,13 +247,12 @@ public class CipherUtil {
 
     
     public static void readAndSetKeyString() {
-        try {
-            Scanner in = new Scanner(new FileReader("/opt/app/music/etc/properties.txt"));
+        try (Scanner in = new Scanner(new FileReader("/opt/app/music/etc/properties.txt"))) {
+            
             StringBuilder sb = new StringBuilder();
             while(in.hasNext()) {
                 sb.append(in.next());
             }
-            in.close();
             keyString = sb.toString();
         } catch (FileNotFoundException e) {
             logger.error(EELFLoggerDelegate.errorLogger, e.getMessage());