lttng: make FileOffsetMapper try-with-resources in #getOutputFromCommand
authorMatthew Khouzam <matthew.khouzam@ericsson.com>
Tue, 27 Oct 2015 19:55:13 +0000 (15:55 -0400)
committerMatthew Khouzam <matthew.khouzam@ericsson.com>
Fri, 20 Nov 2015 21:13:54 +0000 (16:13 -0500)
Change-Id: I8c1dc1e1f81ddd4c4f442af11f91450d73142741
Signed-off-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/59055
Reviewed-by: Hudson CI
lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/internal/lttng2/ust/core/analysis/debuginfo/FileOffsetMapper.java

index 9bbe9ccccc324a670225ef4351d58de226fc3e0e..5acb66c8a93f076bff415a6904d8b8d98ab4886c 100644 (file)
@@ -93,12 +93,12 @@ public final class FileOffsetMapper {
             builder.redirectErrorStream(true);
 
             Process p = builder.start();
-            BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()));
-            int ret = p.waitFor();
-            List<String> lines = br.lines().collect(Collectors.toList());
-
-            return (ret == 0 ? lines : null);
+            try (BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()));) {
+                int ret = p.waitFor();
+                List<String> lines = br.lines().collect(Collectors.toList());
 
+                return (ret == 0 ? lines : null);
+            }
         } catch (IOException | InterruptedException e) {
             return null;
         }
This page took 0.026761 seconds and 5 git commands to generate.