ctf: make CTFStreamInput no longer autoclosable
authorMatthew Khouzam <matthew.khouzam@ericsson.com>
Wed, 12 Nov 2014 21:44:40 +0000 (16:44 -0500)
committerMatthew Khouzam <matthew.khouzam@ericsson.com>
Wed, 19 Nov 2014 14:53:48 +0000 (09:53 -0500)
This does not hold any resources. A rule of thumb is "if and only if it ends in reader, it is autoclosable"

Change-Id: I5c02a139eeda663f0ef721151cb6cbc4206a0448
Signed-off-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/36371
Tested-by: Hudson CI
Reviewed-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
org.eclipse.tracecompass.ctf.core.tests/src/org/eclipse/tracecompass/ctf/core/tests/trace/CTFStreamInputReaderTest.java
org.eclipse.tracecompass.ctf.core.tests/src/org/eclipse/tracecompass/ctf/core/tests/trace/CTFStreamTest.java
org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/trace/CTFStreamInput.java
org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/trace/CTFTrace.java

index 2ae13de2e889416e0060cbe278e5245a007e62e0..67706e9fdc8c93f175d3093c3759e0ccdca30eb7 100644 (file)
@@ -71,7 +71,7 @@ public class CTFStreamInputReaderTest {
                         new StructDeclaration(0),
                         null,
                         "packet",
-                        wrap( "field" ),
+                        wrap("field"),
                         new Definition[] { new StringDefinition(new StringDeclaration(), null, "field", "test") }),
                 null)
                 );
@@ -114,8 +114,8 @@ public class CTFStreamInputReaderTest {
      */
     @Test(expected = CTFReaderException.class)
     public void testStreamInputReader_invalid() throws CTFReaderException, IOException {
-        try (CTFStreamInput streamInput = new CTFStreamInput(new CTFStream(new CTFTrace("")), new File(""));
-                CTFStreamInputReader result = new CTFStreamInputReader(streamInput)) {
+        CTFStreamInput streamInput = new CTFStreamInput(new CTFStream(new CTFTrace("")), new File(""));
+        try (CTFStreamInputReader result = new CTFStreamInputReader(streamInput)) {
             assertNotNull(result);
         }
     }
index 310e0117e6827fbdb13476a03ffaecd7b167862d..a1b79253fecdbd59e0e742a3417122aae5d49860 100644 (file)
@@ -17,7 +17,6 @@ import static org.junit.Assume.assumeTrue;
 
 import java.io.File;
 import java.io.FilenameFilter;
-import java.io.IOException;
 import java.util.Set;
 
 import org.eclipse.jdt.annotation.NonNull;
@@ -30,7 +29,6 @@ import org.eclipse.tracecompass.ctf.core.trace.CTFStreamInput;
 import org.eclipse.tracecompass.ctf.core.trace.CTFTrace;
 import org.eclipse.tracecompass.internal.ctf.core.event.EventDeclaration;
 import org.eclipse.tracecompass.internal.ctf.core.event.metadata.exceptions.ParseException;
-import org.junit.After;
 import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -72,11 +70,6 @@ public class CTFStreamTest {
         fixture.addInput(fInput);
     }
 
-    @After
-    public void tearDown() throws IOException {
-        fInput.close();
-    }
-
     @NonNull
     private static File createFile() {
         File path = new File(testTrace.getPath());
index 73a35d496c22f5f6863eacd2d9e02ceb8057f6b5..10a1add781a8598c0938ccfd79f3c7d93031054d 100644 (file)
@@ -44,8 +44,7 @@ import org.eclipse.tracecompass.internal.ctf.core.trace.StreamInputPacketIndexEn
  *
  * @since 3.0
  */
-// TODO: remove AutoCloseable
-public class CTFStreamInput implements IDefinitionScope, AutoCloseable {
+public class CTFStreamInput implements IDefinitionScope {
 
     // ------------------------------------------------------------------------
     // Attributes
@@ -102,10 +101,6 @@ public class CTFStreamInput implements IDefinitionScope, AutoCloseable {
         fIndex = new StreamInputPacketIndex();
     }
 
-    @Override
-    public void close() throws IOException {
-    }
-
     // ------------------------------------------------------------------------
     // Getters/Setters/Predicates
     // ------------------------------------------------------------------------
index 2c48a4959dd81c5bf479a894b41ffc627e7619e7..37034189d1412371bc25f05aa4eb477a2e96c42c 100644 (file)
@@ -949,8 +949,6 @@ public class CTFTrace implements IDefinitionScope {
      *             The file must exist
      * @since 3.0
      */
-    // TODO: remove suppress warning
-    @SuppressWarnings("resource")
     public void addStream(long id, File streamFile) throws CTFReaderException {
         CTFStream stream = null;
         final File file = streamFile;
This page took 0.027231 seconds and 5 git commands to generate.