tmf: Switch tmf.ui to Java 7 + fix warnings
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / views / callstack / FunctionNameMapper.java
index cf8823952b3116f893e8eb3923cc505d1bdf7a51..9c56c8c817b942920a4e818dde04bc1b520cc757 100644 (file)
@@ -31,17 +31,10 @@ import org.eclipse.jdt.annotation.Nullable;
 class FunctionNameMapper {
 
     public static @Nullable Map<String, String> mapFromNmTextFile(File mappingFile) {
-        Map<String, String> map = new HashMap<String, String>();
+        Map<String, String> map = new HashMap<>();
 
-        FileReader fr;
-        try {
-            fr = new FileReader(mappingFile);
-        } catch (FileNotFoundException e) {
-            return null;
-        }
-        BufferedReader reader = new BufferedReader(fr);
-
-        try {
+        try (FileReader fr = new FileReader(mappingFile);
+                BufferedReader reader = new BufferedReader(fr);) {
             for (String line = reader.readLine(); line != null; line = reader.readLine()) {
                 String[] elems = line.split(" "); //$NON-NLS-1$
                 /* Only lines with 3 elements contain addresses */
@@ -52,13 +45,10 @@ class FunctionNameMapper {
                     map.put(address, name);
                 }
             }
-
+        } catch (FileNotFoundException e) {
+            return null;
         } catch (IOException e) {
             /* Stop reading the file at this point */
-        } finally {
-            try {
-                reader.close();
-            } catch (IOException e) {}
         }
 
         if (map.isEmpty()) {
This page took 0.027541 seconds and 5 git commands to generate.