tmf: Fix simple resource leak warnings
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ctf.ui.swtbot.tests / src / org / eclipse / linuxtools / tmf / ctf / ui / swtbot / tests / AbstractImportAndReadSmokeTest.java
index a23b8f494148250d4db7538ac19225d9ba573634..d170d53eca334198f2671d1187be8082cfaf9a99 100644 (file)
@@ -310,14 +310,13 @@ public abstract class AbstractImportAndReadSmokeTest {
      * @return the event at given rank
      */
     protected CtfTmfEvent getEvent(int rank) {
-        CtfTmfTrace trace = fTrace.getTrace();
-        ITmfContext ctx = trace.seekEvent(0);
-        for (int i = 0; i < rank; i++) {
-            trace.getNext(ctx);
+        try (CtfTmfTrace trace = fTrace.getTrace()) {
+            ITmfContext ctx = trace.seekEvent(0);
+            for (int i = 0; i < rank; i++) {
+                trace.getNext(ctx);
+            }
+            return trace.getNext(ctx);
         }
-        final CtfTmfEvent retVal = trace.getNext(ctx);
-        trace.dispose();
-        return retVal;
     }
 
     /**
This page took 0.025334 seconds and 5 git commands to generate.