Skip to content

FALSE NEGATIVE: PULSE_RESOURCE_LEAK misses an unclosed stream returned by Files.newInputStream() #2110

Description

@chisa22

Hi, I found a false negative in Infer 1.3.0 when Files.newInputStream() returns a stream that is used but never closed.

Affected tool

Infer 1.3.0

Affected checker

Infer PULSE_RESOURCE_LEAK

Minimal reproducer

import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;

class InferLeakFilesNewInputStream {
  void test(Path path) throws IOException {
    InputStream stream = Files.newInputStream(path);
    stream.read();
  }
}

Reproduction command

infer --version
infer run --pulse --enable-issue-type PULSE_RESOURCE_LEAK -- javac spotbugs-to-infer-resourceleak-fn-files-new-input-stream.java

Current behavior

Infer completes successfully but produces no PULSE_RESOURCE_LEAK finding.

Expected behavior

Infer should report PULSE_RESOURCE_LEAK at line 8 because Files.newInputStream() returns an InputStream that is used but never closed.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions