ctf: Remove AutoCloseable from CtfTmfTrace
authorAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Tue, 7 Jul 2015 20:29:01 +0000 (16:29 -0400)
committerAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Tue, 8 Sep 2015 17:55:21 +0000 (13:55 -0400)
Implementations of TmfTrace should not be AutoCloseable,
since they are exposed by other objects through getters.

Change-Id: Ibdb9b056802262cb3e0d67b6f5d3434f79c7face
Signed-off-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
Reviewed-on: https://git.eclipse.org/r/51542
Reviewed-by: Hudson CI
22 files changed:
ctf/org.eclipse.tracecompass.tmf.ctf.core.tests/shared/org/eclipse/tracecompass/tmf/ctf/core/tests/shared/CtfTmfTestTrace.java
ctf/org.eclipse.tracecompass.tmf.ctf.core.tests/src/org/eclipse/tracecompass/tmf/ctf/core/tests/event/CtfTmfEventTest.java
ctf/org.eclipse.tracecompass.tmf.ctf.core.tests/src/org/eclipse/tracecompass/tmf/ctf/core/tests/event/CtfTmfLostEventsTest.java
ctf/org.eclipse.tracecompass.tmf.ctf.core.tests/src/org/eclipse/tracecompass/tmf/ctf/core/tests/iterator/CtfIteratorTest.java
ctf/org.eclipse.tracecompass.tmf.ctf.core.tests/src/org/eclipse/tracecompass/tmf/ctf/core/tests/temp/headless/Benchmark.java
ctf/org.eclipse.tracecompass.tmf.ctf.core.tests/src/org/eclipse/tracecompass/tmf/ctf/core/tests/trace/CtfTmfTraceTest.java
ctf/org.eclipse.tracecompass.tmf.ctf.core.tests/src/org/eclipse/tracecompass/tmf/ctf/core/tests/trace/CtfTmfTraceValidateTest.java
ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/trace/CtfTmfTrace.java
ctf/org.eclipse.tracecompass.tmf.ctf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ctf/ui/swtbot/tests/AbstractImportAndReadSmokeTest.java
lttng/org.eclipse.tracecompass.lttng2.kernel.core.tests/perf/org/eclipse/tracecompass/lttng2/kernel/core/tests/perf/analysis/AnalysisBenchmark.java
lttng/org.eclipse.tracecompass.lttng2.kernel.core.tests/perf/org/eclipse/tracecompass/lttng2/kernel/core/tests/perf/analysis/StatisticsAnalysisBenchmark.java
lttng/org.eclipse.tracecompass.lttng2.kernel.core.tests/perf/org/eclipse/tracecompass/lttng2/kernel/core/tests/perf/event/matching/EventMatchingBenchmark.java
lttng/org.eclipse.tracecompass.lttng2.kernel.core.tests/perf/org/eclipse/tracecompass/lttng2/kernel/core/tests/perf/event/matching/TraceSynchronizationBenchmark.java
lttng/org.eclipse.tracecompass.lttng2.kernel.core.tests/src/org/eclipse/tracecompass/lttng2/kernel/core/tests/analysis/kernel/LttngKernelAnalysisTest.java
lttng/org.eclipse.tracecompass.lttng2.kernel.core.tests/src/org/eclipse/tracecompass/lttng2/kernel/core/tests/analysis/kernel/statesystem/GenerateTestValues.java
lttng/org.eclipse.tracecompass.lttng2.kernel.core.tests/src/org/eclipse/tracecompass/lttng2/kernel/core/tests/event/matchandsync/ExperimentSyncTest.java
lttng/org.eclipse.tracecompass.lttng2.kernel.core.tests/src/org/eclipse/tracecompass/lttng2/kernel/core/tests/event/matchandsync/MatchAndSyncTest.java
lttng/org.eclipse.tracecompass.lttng2.kernel.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/kernel/ui/swtbot/tests/ImportAndReadKernelSmokeTest.java
lttng/org.eclipse.tracecompass.lttng2.ust.core.tests/src/org/eclipse/tracecompass/lttng2/ust/core/tests/callstack/AbstractProviderTest.java
lttng/org.eclipse.tracecompass.lttng2.ust.core/META-INF/MANIFEST.MF
lttng/org.eclipse.tracecompass.lttng2.ust.core/pom.xml
tmf/org.eclipse.tracecompass.tmf.analysis.xml.core.tests/src/org/eclipse/tracecompass/tmf/analysis/xml/core/tests/stateprovider/StateProviderModuleTest.java

index 1abbdbd8fbc3742014393c4fbcc06d0bea6c9df0..6ccc5249064c7374a85d96f43cf17420837043aa 100644 (file)
@@ -91,7 +91,7 @@ public enum CtfTmfTestTrace {
     public synchronized CtfTmfTrace getTrace() {
         CtfTmfTraceStub trace = fTrace;
         if (trace != null) {
-            trace.close();
+            trace.dispose();
         }
         trace = new CtfTmfTraceStub();
         try {
index 6cb78edd786a189ee048a622a71cd96b1767686f..f2f2172826a021ddd396bc16e3b6be0e3cb59ac7 100644 (file)
@@ -54,12 +54,13 @@ public class CtfTmfEventTest {
     @Before
     public void setUp() {
         assumeTrue(testTrace.exists());
-        try (CtfTmfTrace trace = testTrace.getTrace();
-                CtfIterator tr = (CtfIterator) trace.createIterator();) {
+        CtfTmfTrace trace = testTrace.getTrace();
+        try (CtfIterator tr = (CtfIterator) trace.createIterator();) {
             tr.advance();
             fixture = tr.getCurrentEvent();
             nullEvent = CtfTmfEventFactory.getNullEvent(trace);
         }
+        trace.dispose();
     }
 
     /**
@@ -153,9 +154,9 @@ public class CtfTmfEventTest {
     @Test
     public void testGetters() {
         long rank = fixture.getRank();
-        try (CtfTmfTrace trace = fixture.getTrace();) {
-            assertEquals("kernel", trace.getName());
-        }
+        CtfTmfTrace trace = fixture.getTrace();
+        assertEquals("kernel", trace.getName());
+
         String reference = fixture.getChannel();
         int cpu = fixture.getCPU();
         ITmfEventType type = fixture.getType();
index be188527cb1294b390f57e1272343c2c5a4a03e8..d56beb93a4c7b26e66fe7dbc876082fe69c08e0b 100644 (file)
@@ -104,23 +104,24 @@ public class CtfTmfLostEventsTest {
     public void testNbEventsBug475007() {
         final CtfTmfTestTrace tmfTestTrace = CtfTmfTestTrace.DYNSCOPE;
         assumeTrue(tmfTestTrace.exists());
-        try (CtfTmfTrace trace = tmfTestTrace.getTrace()) {
-            trace.indexTrace(true);
-
-            final long expectedReal = 100003;
-            final long expectedLost = 1;
-
-            EventCountRequest req = new EventCountRequest();
-            trace.sendRequest(req);
-            try {
-                req.waitForCompletion();
-            } catch (InterruptedException e) {
-                e.printStackTrace();
-            }
+        CtfTmfTrace trace = tmfTestTrace.getTrace();
+        trace.indexTrace(true);
+
+        final long expectedReal = 100003;
+        final long expectedLost = 1;
 
-            assertEquals(expectedReal, req.getReal());
-            assertEquals(expectedLost, req.getLost());
+        EventCountRequest req = new EventCountRequest();
+        trace.sendRequest(req);
+        try {
+            req.waitForCompletion();
+        } catch (InterruptedException e) {
+            e.printStackTrace();
         }
+
+        assertEquals(expectedReal, req.getReal());
+        assertEquals(expectedLost, req.getLost());
+
+        trace.dispose();
     }
 
     /**
index d5d8271c30337560a116413ac84287504ed12021..09a0c6786a0bb434a3a2a52ae39913c742c3f1bc 100644 (file)
@@ -157,9 +157,8 @@ public class CtfIteratorTest {
      */
     @Test
     public void testGetCtfTmfTrace() {
-        try (CtfTmfTrace result = iterator.getCtfTmfTrace();) {
-            assertNotNull(result);
-        }
+        CtfTmfTrace result = iterator.getCtfTmfTrace();
+        assertNotNull(result);
     }
 
     /**
index 88ef3ea009de27fc4b958674c7cc65199479ce81..2f8d027ac435c78f379535905a4052f572f4b6b8 100644 (file)
@@ -44,41 +44,42 @@ public class Benchmark {
         long start, stop;
         for (int loops = 0; loops < NUM_LOOPS; loops++) {
             nbEvent = 0L;
-            try (CtfTmfTrace trace = new CtfTmfTrace();) {
-                try {
-                    trace.initTrace(null, TRACE_PATH, CtfTmfEvent.class);
-                } catch (final TmfTraceException e) {
-                    loops = NUM_LOOPS + 1;
-                    break;
-                }
+            CtfTmfTrace trace = new CtfTmfTrace();
+            try {
+                trace.initTrace(null, TRACE_PATH, CtfTmfEvent.class);
+            } catch (final TmfTraceException e) {
+                loops = NUM_LOOPS + 1;
+                break;
+            }
 
-                start = System.nanoTime();
-                if (nbEvent != -1) {
-                    final CtfTmfContext traceReader = (CtfTmfContext) trace.seekEvent(0);
+            start = System.nanoTime();
+            if (nbEvent != -1) {
+                final CtfTmfContext traceReader = (CtfTmfContext) trace.seekEvent(0);
 
-                    start = System.nanoTime();
-                    CtfTmfEvent current = traceReader.getCurrentEvent();
-                    while (current != null) {
-                        nbEvent++;
-                        if (USE_TEXT) {
+                start = System.nanoTime();
+                CtfTmfEvent current = traceReader.getCurrentEvent();
+                while (current != null) {
+                    nbEvent++;
+                    if (USE_TEXT) {
 
-                            System.out.println("Event " + nbEvent + " Time "
-                                    + current.getTimestamp().toString() + " type " + current.getType().getName()
-                                    + " on CPU " + current.getCPU() + " " + current.getContent().toString());
-                        }
-                        // advance the trace to the next event.
-                        boolean hasMore = traceReader.advance();
-                        if (hasMore) {
-                            // you can know the trace has more events.
-                        }
-                        current = traceReader.getCurrentEvent();
+                        System.out.println("Event " + nbEvent + " Time "
+                                + current.getTimestamp().toString() + " type " + current.getType().getName()
+                                + " on CPU " + current.getCPU() + " " + current.getContent().toString());
                     }
+                    // advance the trace to the next event.
+                    boolean hasMore = traceReader.advance();
+                    if (hasMore) {
+                        // you can know the trace has more events.
+                    }
+                    current = traceReader.getCurrentEvent();
                 }
-                stop = System.nanoTime();
-                System.out.print('.');
-                final double time = (stop - start) / (double) nbEvent;
-                benchs.add(time);
-            } // trace.close()
+            }
+            stop = System.nanoTime();
+            System.out.print('.');
+            final double time = (stop - start) / (double) nbEvent;
+            benchs.add(time);
+
+            trace.dispose();
         }
         System.out.println("");
         double avg = 0;
index 87600bae04e5ffb848bd1bfb83f702172bec81a0..efd6a214123448991e37e45a7ba59c662ff70c46 100644 (file)
@@ -88,14 +88,16 @@ public class CtfTmfTraceTest {
      */
     @Test
     public void testCtfTmfTrace() {
-        try (CtfTmfTrace result = new CtfTmfTrace();) {
-            assertNotNull(result);
-            assertEquals(1000, result.getCacheSize());
-            assertEquals(0L, result.getNbEvents());
-            assertEquals(0L, result.getStreamingInterval());
-            assertNull(result.getResource());
-            assertNull(result.getType());
-        }
+        CtfTmfTrace result = new CtfTmfTrace();
+
+        assertNotNull(result);
+        assertEquals(1000, result.getCacheSize());
+        assertEquals(0L, result.getNbEvents());
+        assertEquals(0L, result.getStreamingInterval());
+        assertNull(result.getResource());
+        assertNull(result.getType());
+
+        result.dispose();
     }
 
     /**
@@ -123,9 +125,9 @@ public class CtfTmfTraceTest {
      * Run the void dispose() method test.
      */
     @Test
-    public void testClose() {
-        try (CtfTmfTrace emptyFixture = new CtfTmfTrace();) {
-        }
+    public void testDispose() {
+        CtfTmfTrace emptyFixture = new CtfTmfTrace();
+        emptyFixture.dispose();
     }
 
     /**
@@ -133,10 +135,11 @@ public class CtfTmfTraceTest {
      */
     @Test
     public void testGetCacheSize() {
-        try (CtfTmfTrace emptyFixture = new CtfTmfTrace();) {
-            int result = emptyFixture.getCacheSize();
-            assertEquals(1000, result);
-        }
+        CtfTmfTrace emptyFixture = new CtfTmfTrace();
+        int result = emptyFixture.getCacheSize();
+        assertEquals(1000, result);
+
+        emptyFixture.dispose();
     }
 
     /**
index 8826f05267b1432be4a2b18e8bdd3c51cd2c587c..929b931cdbc54f9fc4416e095b3456c15fbbf7f6 100644 (file)
@@ -105,38 +105,38 @@ public class CtfTmfTraceValidateTest {
      */
     @Test
     public void testValidate() {
-        try (CtfTmfTrace trace = new CtfTmfTrace();) {
-            IStatus status = trace.validate(null, fTrace);
-            assertEquals(toString(), fServerity, status.getSeverity());
+        CtfTmfTrace trace = new CtfTmfTrace();
+        IStatus status = trace.validate(null, fTrace);
+        assertEquals(toString(), fServerity, status.getSeverity());
 
-            if (fHasException) {
-                assertNotNull(toString(), status.getException());
-            }
-            switch (status.getSeverity()) {
-            case IStatus.OK: {
-                assertTrue(status instanceof CtfTraceValidationStatus);
-                CtfTraceValidationStatus ctfStatus = (CtfTraceValidationStatus) status;
-                assertEquals(toString(), fConfidence, ctfStatus.getConfidence());
-                assertNotNull(ctfStatus.getEnvironment());
-                break;
-            }
-            case IStatus.WARNING: {
-                assertTrue(status instanceof TraceValidationStatus);
-                TraceValidationStatus ctfStatus = (TraceValidationStatus) status;
-                assertEquals(fConfidence, ctfStatus.getConfidence());
-                break;
-            }
-            case IStatus.ERROR: {
-                // nothing else to check here
-                break;
-            }
-            default:
-                // no other severity should be returned
-                fail();
-                break;
-            }
-            assertEquals(fServerity, status.getSeverity());
+        if (fHasException) {
+            assertNotNull(toString(), status.getException());
         }
+        switch (status.getSeverity()) {
+        case IStatus.OK: {
+            assertTrue(status instanceof CtfTraceValidationStatus);
+            CtfTraceValidationStatus ctfStatus = (CtfTraceValidationStatus) status;
+            assertEquals(toString(), fConfidence, ctfStatus.getConfidence());
+            assertNotNull(ctfStatus.getEnvironment());
+            break;
+        }
+        case IStatus.WARNING: {
+            assertTrue(status instanceof TraceValidationStatus);
+            TraceValidationStatus ctfStatus = (TraceValidationStatus) status;
+            assertEquals(fConfidence, ctfStatus.getConfidence());
+            break;
+        }
+        case IStatus.ERROR: {
+            // nothing else to check here
+            break;
+        }
+        default:
+            // no other severity should be returned
+            fail();
+            break;
+        }
+        assertEquals(fServerity, status.getSeverity());
+        trace.dispose();
     }
 
 }
index 786efe899b1e7ce4526ad8e276d8c82c7c053c70..1c260df7d8bc0012f4cdc3ddfc4f1e8db7efb60b 100644 (file)
@@ -84,7 +84,7 @@ import com.google.common.collect.ImmutableSet;
  */
 public class CtfTmfTrace extends TmfTrace
         implements ITmfTraceProperties, ITmfPersistentlyIndexable,
-        ITmfTraceWithPreDefinedEvents, AutoCloseable {
+        ITmfTraceWithPreDefinedEvents {
 
     // -------------------------------------------
     // Constants
@@ -205,11 +205,6 @@ public class CtfTmfTrace extends TmfTrace
         }
     }
 
-    @Override
-    public void close() {
-        dispose();
-    }
-
     @Override
     public synchronized void dispose() {
         fIteratorManager.dispose();
index 2d64070024369646a2157780f8bee9b6de6fb0a2..5dfdb1b578a6a9b6df00d879f2a9cac148e3afcf 100644 (file)
@@ -236,18 +236,20 @@ public abstract class AbstractImportAndReadSmokeTest {
 
     /**
      * Gets an event at a given rank
+     *
      * @param rank
      *            a rank
      * @return the event at given rank
      */
     protected CtfTmfEvent getEvent(int rank) {
-        try (CtfTmfTrace trace = fTrace.getTrace()) {
-            ITmfContext ctx = trace.seekEvent(0);
-            for (int i = 0; i < rank; i++) {
-                trace.getNext(ctx);
-            }
-            return trace.getNext(ctx);
+        CtfTmfTrace trace = fTrace.getTrace();
+        ITmfContext ctx = trace.seekEvent(0);
+        for (int i = 0; i < rank; i++) {
+            trace.getNext(ctx);
         }
+        CtfTmfEvent ret = trace.getNext(ctx);
+        trace.dispose();
+        return ret;
     }
 
     /**
index 3233ccebee89d099825f8a52a19399b8e38e5e76..fc7655246350de860f14045c771f99b141f4af48 100644 (file)
@@ -63,8 +63,10 @@ public class AnalysisBenchmark {
         }
 
         for (int i = 0; i < LOOP_COUNT; i++) {
+            LttngKernelTrace trace = null;
             IAnalysisModule module = null;
-            try (LttngKernelTrace trace = new LttngKernelTrace()) {
+            try {
+                trace = new LttngKernelTrace();
                 module = new KernelAnalysisModule();
                 module.setId("test");
                 trace.initTrace(null, testTrace.getPath(), CtfTmfEvent.class);
@@ -89,6 +91,9 @@ public class AnalysisBenchmark {
                 if (module != null) {
                     module.dispose();
                 }
+                if (trace != null) {
+                    trace.dispose();
+                }
             }
         }
         pm.commit();
index 4051051dac152a76540e9d4a909f72ead08a1a27..9dc8c31337064f2fc2870e959b184f083c960a62 100644 (file)
@@ -103,8 +103,10 @@ public class StatisticsAnalysisBenchmark {
         }
 
         for (int i = 0; i < LOOP_COUNT; i++) {
+            LttngKernelTrace trace = null;
             TmfStatisticsModule module = null;
-            try (LttngKernelTrace trace = new LttngKernelTrace()) {
+            try {
+                trace = new LttngKernelTrace();
                 module = new TmfStatisticsModule();
                 module.setId("test");
                 trace.initTrace(null, testTrace.getPath(), CtfTmfEvent.class);
@@ -143,6 +145,9 @@ public class StatisticsAnalysisBenchmark {
                 if (module != null) {
                     module.dispose();
                 }
+                if (trace != null) {
+                    trace.dispose();
+                }
             }
         }
         pm.commit();
index 4e35cf47163bce9c2309776b2033fd6c37d75373..bc1855e4423a01e1ee7ded41b939f8a75f5e3034 100644 (file)
@@ -58,11 +58,16 @@ public class EventMatchingBenchmark {
     public void testSmallTraces() {
         assumeTrue(CtfTmfTestTrace.SYNC_SRC.exists());
         assumeTrue(CtfTmfTestTrace.SYNC_DEST.exists());
-        try (CtfTmfTrace trace1 = CtfTmfTestTrace.SYNC_SRC.getTrace();
-                CtfTmfTrace trace2 = CtfTmfTestTrace.SYNC_DEST.getTrace();) {
-            Set<ITmfTrace> traces = ImmutableSet.of((ITmfTrace) trace1, trace2);
-            runCpuTest(traces, "Match TCP events", 100);
-        }
+
+        CtfTmfTrace trace1 = CtfTmfTestTrace.SYNC_SRC.getTrace();
+        CtfTmfTrace trace2 = CtfTmfTestTrace.SYNC_DEST.getTrace();
+
+        Set<ITmfTrace> traces = ImmutableSet.of((ITmfTrace) trace1, trace2);
+        runCpuTest(traces, "Match TCP events", 100);
+
+        trace1.dispose();
+        trace2.dispose();
+
     }
 
     /**
@@ -73,13 +78,18 @@ public class EventMatchingBenchmark {
         assumeTrue(CtfTmfTestTrace.DJANGO_CLIENT.exists());
         assumeTrue(CtfTmfTestTrace.DJANGO_DB.exists());
         assumeTrue(CtfTmfTestTrace.DJANGO_HTTPD.exists());
-        try (CtfTmfTrace trace1 = CtfTmfTestTrace.DJANGO_CLIENT.getTrace();
-                CtfTmfTrace trace2 = CtfTmfTestTrace.DJANGO_DB.getTrace();
-                CtfTmfTrace trace3 = CtfTmfTestTrace.DJANGO_HTTPD.getTrace();) {
-            Set<ITmfTrace> traces = ImmutableSet.of((ITmfTrace) trace1, trace2, trace3);
-            runCpuTest(traces, "Django traces", 10);
-            runMemoryTest(traces, "Django traces", 10);
-        }
+
+        CtfTmfTrace trace1 = CtfTmfTestTrace.DJANGO_CLIENT.getTrace();
+        CtfTmfTrace trace2 = CtfTmfTestTrace.DJANGO_DB.getTrace();
+        CtfTmfTrace trace3 = CtfTmfTestTrace.DJANGO_HTTPD.getTrace();
+
+        Set<ITmfTrace> traces = ImmutableSet.of((ITmfTrace) trace1, trace2, trace3);
+        runCpuTest(traces, "Django traces", 10);
+        runMemoryTest(traces, "Django traces", 10);
+
+        trace1.dispose();
+        trace2.dispose();
+        trace3.dispose();
     }
 
     private static void runCpuTest(Set<ITmfTrace> testTraces, String testName, int loop_count) {
index 802bc8ac9d3853d700c025d92c988ee10e99b6c6..0c1c41f9652a178e01b45f3f622da7482365bd89 100644 (file)
@@ -61,12 +61,15 @@ public class TraceSynchronizationBenchmark {
     public void testSmallTraces() {
         assumeTrue(CtfTmfTestTrace.SYNC_SRC.exists());
         assumeTrue(CtfTmfTestTrace.SYNC_DEST.exists());
-        try (CtfTmfTrace trace1 = CtfTmfTestTrace.SYNC_SRC.getTrace();
-                CtfTmfTrace trace2 = CtfTmfTestTrace.SYNC_DEST.getTrace();) {
-            ITmfTrace[] traces = { trace1, trace2 };
-            TmfExperiment experiment = new TmfExperiment(CtfTmfEvent.class, "Test experiment", traces, TmfExperiment.DEFAULT_INDEX_PAGE_SIZE, null);
-            runCpuTest(experiment, "Match TCP events", 40);
-        }
+        CtfTmfTrace trace1 = CtfTmfTestTrace.SYNC_SRC.getTrace();
+        CtfTmfTrace trace2 = CtfTmfTestTrace.SYNC_DEST.getTrace();
+
+        ITmfTrace[] traces = { trace1, trace2 };
+        TmfExperiment experiment = new TmfExperiment(CtfTmfEvent.class, "Test experiment", traces, TmfExperiment.DEFAULT_INDEX_PAGE_SIZE, null);
+        runCpuTest(experiment, "Match TCP events", 40);
+
+        trace1.dispose();
+        trace2.dispose();
     }
 
     /**
@@ -77,14 +80,19 @@ public class TraceSynchronizationBenchmark {
         assumeTrue(CtfTmfTestTrace.DJANGO_CLIENT.exists());
         assumeTrue(CtfTmfTestTrace.DJANGO_DB.exists());
         assumeTrue(CtfTmfTestTrace.DJANGO_HTTPD.exists());
-        try (CtfTmfTrace trace1 = CtfTmfTestTrace.DJANGO_CLIENT.getTrace();
-                CtfTmfTrace trace2 = CtfTmfTestTrace.DJANGO_DB.getTrace();
-                CtfTmfTrace trace3 = CtfTmfTestTrace.DJANGO_HTTPD.getTrace();) {
-            ITmfTrace[] traces = { trace1, trace2, trace3 };
-            TmfExperiment experiment = new TmfExperiment(CtfTmfEvent.class, "Test experiment", traces, TmfExperiment.DEFAULT_INDEX_PAGE_SIZE, null);
-            runCpuTest(experiment, "Django traces", 10);
-            runMemoryTest(experiment, "Django traces", 10);
-        }
+
+        CtfTmfTrace trace1 = CtfTmfTestTrace.DJANGO_CLIENT.getTrace();
+        CtfTmfTrace trace2 = CtfTmfTestTrace.DJANGO_DB.getTrace();
+        CtfTmfTrace trace3 = CtfTmfTestTrace.DJANGO_HTTPD.getTrace();
+
+        ITmfTrace[] traces = { trace1, trace2, trace3 };
+        TmfExperiment experiment = new TmfExperiment(CtfTmfEvent.class, "Test experiment", traces, TmfExperiment.DEFAULT_INDEX_PAGE_SIZE, null);
+        runCpuTest(experiment, "Django traces", 10);
+        runMemoryTest(experiment, "Django traces", 10);
+
+        trace1.dispose();
+        trace2.dispose();
+        trace3.dispose();
     }
 
     private static void runCpuTest(TmfExperiment experiment, String testName, int loop_count) {
index 6d6a69706159c40dca1b28dc665d40757dcd68b1..b5a3abd2e4ae47b24ba698aa44afb0885d3b25b2 100644 (file)
@@ -124,13 +124,13 @@ public class LttngKernelAnalysisTest {
 
         /* Test with a CTF trace that does not have required events */
         assumeTrue(CtfTmfTestTrace.CYG_PROFILE.exists());
-        try (CtfTmfTrace trace = CtfTmfTestTrace.CYG_PROFILE.getTrace();) {
-            /*
-             * TODO: This should be false, but for now there is no mandatory
-             * events in the kernel analysis so it will return true.
-             */
-            assertTrue(fKernelAnalysisModule.canExecute(trace));
-        }
+        CtfTmfTrace trace = CtfTmfTestTrace.CYG_PROFILE.getTrace();
+        /*
+         * TODO: This should be false, but for now there is no mandatory events
+         * in the kernel analysis so it will return true.
+         */
+        assertTrue(fKernelAnalysisModule.canExecute(trace));
+        trace.dispose();
     }
 
     /**
index a63ca7fba94dc190c580e5d379b93c00f187e2b0..89aaa04f06729276351c7098c3f00a825733a380 100644 (file)
@@ -56,10 +56,10 @@ public class GenerateTestValues {
 
         /* Prepare the files */
         File logFile = File.createTempFile("TestValues", ".java");
-        try (final CtfTmfTrace trace = testTrace.getTrace();
-                PrintWriter writer = new PrintWriter(new FileWriter(logFile), true);) {
+        try (PrintWriter writer = new PrintWriter(new FileWriter(logFile), true);) {
 
             /* Build and query the state system */
+            final CtfTmfTrace trace = testTrace.getTrace();
             TmfStateSystemAnalysisModule module = new KernelAnalysisModule() {
                 @Override
                 protected String getSsFileName() {
@@ -133,6 +133,7 @@ public class GenerateTestValues {
             writer.println();
 
             module.dispose();
+            trace.dispose();
         }
         System.exit(0);
     }
index 9e76fe59c26141d989100bffda60df97c9dbc3ce..49a5b8ab46a96a8adf49407dc737698b2a043eb8 100644 (file)
@@ -64,27 +64,28 @@ public class ExperimentSyncTest {
     public void testExperimentSync() {
         assumeTrue(CtfTmfTestTrace.SYNC_SRC.exists());
         assumeTrue(CtfTmfTestTrace.SYNC_DEST.exists());
-        try (CtfTmfTrace trace1 = CtfTmfTestTrace.SYNC_SRC.getTrace();
-                CtfTmfTrace trace2 = CtfTmfTestTrace.SYNC_DEST.getTrace();) {
+        CtfTmfTrace trace1 = CtfTmfTestTrace.SYNC_SRC.getTrace();
+        CtfTmfTrace trace2 = CtfTmfTestTrace.SYNC_DEST.getTrace();
 
-            ITmfTrace[] traces = { trace1, trace2 };
-            TmfExperiment experiment = new TmfExperiment(traces[0].getEventType(), EXPERIMENT, traces, BLOCK_SIZE, null);
+        ITmfTrace[] traces = { trace1, trace2 };
+        TmfExperiment experiment = new TmfExperiment(traces[0].getEventType(), EXPERIMENT, traces, BLOCK_SIZE, null);
 
-            SynchronizationAlgorithm syncAlgo = experiment.synchronizeTraces(true);
+        SynchronizationAlgorithm syncAlgo = experiment.synchronizeTraces(true);
 
-            ITmfTimestampTransform tt1 = syncAlgo.getTimestampTransform(trace1);
-            ITmfTimestampTransform tt2 = syncAlgo.getTimestampTransform(trace2);
+        ITmfTimestampTransform tt1 = syncAlgo.getTimestampTransform(trace1);
+        ITmfTimestampTransform tt2 = syncAlgo.getTimestampTransform(trace2);
 
-            trace1.setTimestampTransform(tt1);
-            trace2.setTimestampTransform(tt2);
+        trace1.setTimestampTransform(tt1);
+        trace2.setTimestampTransform(tt2);
 
-            assertEquals("TmfTimestampTransformLinearFast [ slope = 0.9999413783703139011056845831168394, offset = 79796507913179.33347660124688298171 ]", tt1.toString());
-            assertEquals(TimestampTransformFactory.getDefaultTransform(), tt2);
+        assertEquals("TmfTimestampTransformLinearFast [ slope = 0.9999413783703139011056845831168394, offset = 79796507913179.33347660124688298171 ]", tt1.toString());
+        assertEquals(TimestampTransformFactory.getDefaultTransform(), tt2);
 
-            assertEquals(syncAlgo.getTimestampTransform(trace1.getHostId()), trace1.getTimestampTransform());
-            assertEquals(syncAlgo.getTimestampTransform(trace2.getHostId()), trace2.getTimestampTransform());
+        assertEquals(syncAlgo.getTimestampTransform(trace1.getHostId()), trace1.getTimestampTransform());
+        assertEquals(syncAlgo.getTimestampTransform(trace2.getHostId()), trace2.getTimestampTransform());
 
-        }
+        trace1.dispose();
+        trace2.dispose();
     }
 
     /**
@@ -96,26 +97,30 @@ public class ExperimentSyncTest {
         assumeTrue(CtfTmfTestTrace.DJANGO_CLIENT.exists());
         assumeTrue(CtfTmfTestTrace.DJANGO_DB.exists());
         assumeTrue(CtfTmfTestTrace.DJANGO_HTTPD.exists());
-        try (CtfTmfTrace trace1 = CtfTmfTestTrace.DJANGO_CLIENT.getTrace();
-                CtfTmfTrace trace2 = CtfTmfTestTrace.DJANGO_DB.getTrace();
-                CtfTmfTrace trace3 = CtfTmfTestTrace.DJANGO_HTTPD.getTrace();) {
-            ITmfTrace[] traces = { trace1, trace2, trace3 };
-            TmfExperiment experiment = new TmfExperiment(traces[0].getEventType(), EXPERIMENT, traces, BLOCK_SIZE, null);
 
-            SynchronizationAlgorithm syncAlgo = experiment.synchronizeTraces(true);
+        CtfTmfTrace trace1 = CtfTmfTestTrace.DJANGO_CLIENT.getTrace();
+        CtfTmfTrace trace2 = CtfTmfTestTrace.DJANGO_DB.getTrace();
+        CtfTmfTrace trace3 = CtfTmfTestTrace.DJANGO_HTTPD.getTrace();
 
-            ITmfTimestampTransform tt1 = syncAlgo.getTimestampTransform(trace1);
-            ITmfTimestampTransform tt2 = syncAlgo.getTimestampTransform(trace2);
-            ITmfTimestampTransform tt3 = syncAlgo.getTimestampTransform(trace3);
+        ITmfTrace[] traces = { trace1, trace2, trace3 };
+        TmfExperiment experiment = new TmfExperiment(traces[0].getEventType(), EXPERIMENT, traces, BLOCK_SIZE, null);
 
-            trace1.setTimestampTransform(tt1);
-            trace2.setTimestampTransform(tt2);
-            trace3.setTimestampTransform(tt3);
+        SynchronizationAlgorithm syncAlgo = experiment.synchronizeTraces(true);
 
-            assertEquals(TimestampTransformFactory.getDefaultTransform(), tt1);
-            assertEquals("TmfTimestampTransformLinearFast [ slope = 0.9999996313017589597204633828681240, offset = 498490309972.0038068817738527724192 ]", tt2.toString());
-            assertEquals("TmfTimestampTransformLinearFast [ slope = 1.000000119014882262265342419815932, offset = -166652893534.6189900382736187431134 ]", tt3.toString());
+        ITmfTimestampTransform tt1 = syncAlgo.getTimestampTransform(trace1);
+        ITmfTimestampTransform tt2 = syncAlgo.getTimestampTransform(trace2);
+        ITmfTimestampTransform tt3 = syncAlgo.getTimestampTransform(trace3);
 
-        }
+        trace1.setTimestampTransform(tt1);
+        trace2.setTimestampTransform(tt2);
+        trace3.setTimestampTransform(tt3);
+
+        assertEquals(TimestampTransformFactory.getDefaultTransform(), tt1);
+        assertEquals("TmfTimestampTransformLinearFast [ slope = 0.9999996313017589597204633828681240, offset = 498490309972.0038068817738527724192 ]", tt2.toString());
+        assertEquals("TmfTimestampTransformLinearFast [ slope = 1.000000119014882262265342419815932, offset = -166652893534.6189900382736187431134 ]", tt3.toString());
+
+        trace1.dispose();
+        trace2.dispose();
+        trace3.dispose();
     }
 }
index 29aa3ad59d49b5475af189fb7640fad070444f04..734efda386acab6d85a07e9d2ee61823533a4364 100644 (file)
@@ -46,31 +46,32 @@ public class MatchAndSyncTest {
     public void testMatching() {
         assumeTrue(CtfTmfTestTrace.SYNC_SRC.exists());
         assumeTrue(CtfTmfTestTrace.SYNC_DEST.exists());
-        try (CtfTmfTrace trace1 = CtfTmfTestTrace.SYNC_SRC.getTrace();
-                CtfTmfTrace trace2 = CtfTmfTestTrace.SYNC_DEST.getTrace();) {
+        CtfTmfTrace trace1 = CtfTmfTestTrace.SYNC_SRC.getTrace();
+        CtfTmfTrace trace2 = CtfTmfTestTrace.SYNC_DEST.getTrace();
 
-            List<ITmfTrace> tracearr = new LinkedList<>();
-            tracearr.add(trace1);
-            tracearr.add(trace2);
+        List<ITmfTrace> tracearr = new LinkedList<>();
+        tracearr.add(trace1);
+        tracearr.add(trace2);
 
-            TmfEventMatching.registerMatchObject(new TcpEventMatching());
-            TmfEventMatching.registerMatchObject(new TcpLttngEventMatching());
+        TmfEventMatching.registerMatchObject(new TcpEventMatching());
+        TmfEventMatching.registerMatchObject(new TcpLttngEventMatching());
 
-            TmfEventMatching twoTraceMatch = new TmfEventMatching(tracearr);
-            assertTrue(twoTraceMatch.matchEvents());
+        TmfEventMatching twoTraceMatch = new TmfEventMatching(tracearr);
+        assertTrue(twoTraceMatch.matchEvents());
 
-            /* Set method and fields accessible to make sure the counts are ok */
-            try {
-                /* Verify number of matches */
-                Method method = TmfEventMatching.class.getDeclaredMethod("getProcessingUnit");
-                method.setAccessible(true);
-                IMatchProcessingUnit procUnit = (IMatchProcessingUnit) method.invoke(twoTraceMatch);
-                assertEquals(46, procUnit.countMatches());
-
-            } catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
-                fail(e.getMessage());
-            }
+        /* Set method and fields accessible to make sure the counts are ok */
+        try {
+            /* Verify number of matches */
+            Method method = TmfEventMatching.class.getDeclaredMethod("getProcessingUnit");
+            method.setAccessible(true);
+            IMatchProcessingUnit procUnit = (IMatchProcessingUnit) method.invoke(twoTraceMatch);
+            assertEquals(46, procUnit.countMatches());
 
+        } catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
+            fail(e.getMessage());
+        } finally {
+            trace1.dispose();
+            trace2.dispose();
         }
     }
 
index b0ab589389b35774d0431718f3f0bca334d7c728..f849375a8ef5533c3487c09488bea5e3d2589636 100644 (file)
@@ -68,10 +68,10 @@ public class ImportAndReadKernelSmokeTest extends KernelTest {
         Matcher<IEditorReference> matcher = WidgetMatcherFactory.withPartName(CTT.getTrace().getName());
         IEditorPart iep = fBot.editor(matcher).getReference().getEditor(true);
         final TmfEventsEditor tmfEd = (TmfEventsEditor) iep;
-        try (CtfTmfTrace trace = CtfTmfTestTrace.SYNTHETIC_TRACE.getTrace();) {
-            fDesired1 = getEvent(trace, 100);
-            fDesired2 = getEvent(trace, 10000);
-        }
+        CtfTmfTrace trace = CtfTmfTestTrace.SYNTHETIC_TRACE.getTrace();
+        fDesired1 = getEvent(trace, 100);
+        fDesired2 = getEvent(trace, 10000);
+
         UIThreadRunnable.syncExec(new VoidResult() {
             @Override
             public void run() {
@@ -82,6 +82,7 @@ public class ImportAndReadKernelSmokeTest extends KernelTest {
         testHV(getViewPart("Histogram"));
         testCFV((ControlFlowView) getViewPart("Control Flow"));
         testRV((ResourcesView) getViewPart("Resources"));
+        trace.dispose();
     }
 
     private static void testCFV(ControlFlowView vp) {
index 29a4821cd73a4278416a2fd389a75803feadd916..7fa0c51e9871e9cca3644738e74d756a88a26b7f 100644 (file)
@@ -139,30 +139,31 @@ public abstract class AbstractProviderTest {
     public void testOtherUstTrace() {
         /* Initialize the trace and analysis module */
         File suppDir;
-        try (CtfTmfTrace ustTrace = otherUstTrace.getTrace();) {
-            TestLttngCallStackModule module = null;
+        CtfTmfTrace ustTrace = otherUstTrace.getTrace();
+        TestLttngCallStackModule module = null;
+        try {
+            module = new TestLttngCallStackModule();
             try {
-                module = new TestLttngCallStackModule();
-                try {
-                    assertTrue(module.setTrace(ustTrace));
-                } catch (TmfAnalysisException e) {
-                    fail();
-                }
-                module.schedule();
-                assertTrue(module.waitForCompletion());
-
-                /* Make sure the generated state system exists, but is empty */
-                ITmfStateSystem ss = module.getStateSystem();
-                assertNotNull(ss);
-                assertTrue(ss.getStartTime() >= ustTrace.getStartTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue());
-                assertEquals(0, ss.getNbAttributes());
-            } finally {
-                if (module != null) {
-                    module.dispose();
-                }
+                assertTrue(module.setTrace(ustTrace));
+            } catch (TmfAnalysisException e) {
+                fail();
+            }
+            module.schedule();
+            assertTrue(module.waitForCompletion());
+
+            /* Make sure the generated state system exists, but is empty */
+            ITmfStateSystem ss = module.getStateSystem();
+            assertNotNull(ss);
+            assertTrue(ss.getStartTime() >= ustTrace.getStartTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue());
+            assertEquals(0, ss.getNbAttributes());
+        } finally {
+            if (module != null) {
+                module.dispose();
             }
-            suppDir = new File(TmfTraceManager.getSupplementaryFileDir(ustTrace));
         }
+        suppDir = new File(TmfTraceManager.getSupplementaryFileDir(ustTrace));
+
+        ustTrace.dispose();
         deleteDirectory(suppDir);
         assertFalse(suppDir.exists());
     }
index abc60e790d0ab65fe676c0de65a1d31ca3ca2962..74c78f67640f4ea51d90c8b530b40f3b7b088043 100644 (file)
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
 Bundle-ManifestVersion: 2
 Bundle-Name: %Bundle-Name
 Bundle-Vendor: %Bundle-Vendor
-Bundle-Version: 1.0.0.qualifier
+Bundle-Version: 2.0.0.qualifier
 Bundle-Localization: plugin
 Bundle-SymbolicName: org.eclipse.tracecompass.lttng2.ust.core;singleton:=true
 Bundle-Activator: org.eclipse.tracecompass.internal.lttng2.ust.core.Activator
index 14efe24cc7f18db27f45d704cc9f7e0747b0c783..85be80f9864fd1261d687934a926eee2613138c2 100644 (file)
@@ -18,7 +18,6 @@
   </parent>
 
   <artifactId>org.eclipse.tracecompass.lttng2.ust.core</artifactId>
-  <version>1.0.0-SNAPSHOT</version>
   <packaging>eclipse-plugin</packaging>
 
   <name>Trace Compass LTTng Userspace Tracer Analysis Core Plug-in</name>
index 12fe09b7be35a1476a60a60b55f50ba22a2add59..549ceec26af9a96e1780cb690fba8a07ec8c7818 100644 (file)
@@ -90,13 +90,16 @@ public class StateProviderModuleTest {
 
         fModule.setXmlFile(TmfXmlTestFiles.VALID_FILE.getPath());
 
-        try (CtfTmfTrace trace = CtfTmfTestTrace.KERNEL.getTrace();) {
+        CtfTmfTrace trace = CtfTmfTestTrace.KERNEL.getTrace();
+        try {
             fModule.setTrace(trace);
             fModule.schedule();
-
             assertTrue(fModule.waitForCompletion(new NullProgressMonitor()));
+
         } catch (TmfAnalysisException e) {
             fail("Cannot set trace " + e.getMessage());
+        } finally {
+            trace.dispose();
         }
 
     }
This page took 0.042629 seconds and 5 git commands to generate.