Skip to content

try with resources with Java 11 triggers RCN warnings #756

@ijuma

Description

@ijuma

Tested with spotBugs 3.1.7. The issue doesn't happen with Java 10.

Example:

RCN | Nullcheck of fc at line 629 of value previously dereferenced in org.apache.kafka.common.utils.Utils.readFileAsString(String, Charset)

public static String readFileAsString(String path, Charset charset) throws IOException {
  try (FileChannel fc = FileChannel.open(Paths.get(path))) {
    MappedByteBuffer bb = fc.map(FileChannel.MapMode.READ_ONLY, 0, fc.size()); // line 629
    return StandardCharsets.UTF_8.decode(bb).toString();
  }
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions