Skip to content

Failed

org.eclipse.jdt.core.tests.compiler.regression.ResourceLeakTests.testBug440282 - 1.8 (from org.eclipse.jdt.core.tests.compiler.regression.TestAll)

Failing for the past 4 builds (Since #6 )
Took 0.64 sec.

Error Message

testBug440282 - Eclipse found error(s) but Javac did not find any.
----------- Expected ------------

------------ but was ------------
----------\n
1. ERROR in ResourceLeakFalseNegative.java (at line 39)\n
 return new Foo(reader).read();\n
        ^^^^^^^^^^^^^^^\n
Resource leak: '<unassigned Closeable value>' is never closed\n
----------\n

--------- Difference is ----------
 expected:<[]> but was:<[----------\n
1. ERROR in ResourceLeakFalseNegative.java (at line 39)\n
 return new Foo(reader).read();\n
        ^^^^^^^^^^^^^^^\n
Resource leak: '<unassigned Closeable value>' is never closed\n
----------\n
]>

Stacktrace

junit.framework.ComparisonFailure: testBug440282 - Eclipse found error(s) but Javac did not find any.
----------- Expected ------------

------------ but was ------------
----------\n
1. ERROR in ResourceLeakFalseNegative.java (at line 39)\n
	return new Foo(reader).read();\n
	       ^^^^^^^^^^^^^^^\n
Resource leak: '<unassigned Closeable value>' is never closed\n
----------\n

--------- Difference is ----------
 expected:<[]> but was:<[----------\n
1. ERROR in ResourceLeakFalseNegative.java (at line 39)\n
	return new Foo(reader).read();\n
	       ^^^^^^^^^^^^^^^\n
Resource leak: '<unassigned Closeable value>' is never closed\n
----------\n
]>
	at org.eclipse.jdt.core.tests.junit.extension.TestCase.assertStringEquals(TestCase.java:260)
	at org.eclipse.jdt.core.tests.junit.extension.TestCase.assertEquals(TestCase.java:236)
	at org.eclipse.jdt.core.tests.compiler.regression.AbstractRegressionTest.runJavac(AbstractRegressionTest.java:2044)
	at org.eclipse.jdt.core.tests.compiler.regression.AbstractRegressionTest.runTest(AbstractRegressionTest.java:2814)
	at org.eclipse.jdt.core.tests.compiler.regression.AbstractRegressionTest.runTest(AbstractRegressionTest.java:2539)
	at org.eclipse.jdt.core.tests.compiler.regression.AbstractRegressionTest.runNegativeTest(AbstractRegressionTest.java:2220)
	at org.eclipse.jdt.core.tests.compiler.regression.ResourceLeakTests.testBug440282(ResourceLeakTests.java:5288)

Standard Output

org.eclipse.jdt.core.tests.compiler.regression.ResourceLeakTests#testBug440282 - 1.8
ResourceLeakFalseNegative.java [
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;

public final class ResourceLeakFalseNegative {

  private static final class Foo implements AutoCloseable {
    final InputStreamReader reader;

    Foo(final InputStreamReader reader) {
      this.reader = reader;
    }
    
    public int read() throws IOException {
      return reader.read();
    }

    public void close() throws IOException {
      reader.close();
    }
  }

  private static final class Bar {
    final int read;

    Bar(final InputStreamReader reader) throws IOException {
      read = reader.read();
    }
    
    public int read() {
      return read;
    }
  }

  public final static int foo() throws IOException {
    final FileInputStream in = new FileInputStream("/dev/null");
    final InputStreamReader reader = new InputStreamReader(in);
    try {
      return new Foo(reader).read();
    } finally {
      // even though Foo is not closed, no potential resource leak is reported.
    }
  }

  public final static int bar() throws IOException {
    final FileInputStream in = new FileInputStream("/dev/null");
    final InputStreamReader reader = new InputStreamReader(in);
    try {
      final Bar bar = new Bar(reader);
      return bar.read();
    } finally {
      // Removing the close correctly reports potential resource leak as a warning,
      // because Bar does not implement AutoCloseable.
      reader.close();
    }
  }

  public static void main(String[] args) throws IOException {
    for (;;) {
      foo();
      bar();
    }
  }
}

]


Full results sent to /tmp/comptest/run.1514610271420/1.8.0_131_20171230_000432.txt

Standard Error

----------------------------------------