try-with-resources introduces an implicit null check which is flagged as an explicit check

Issue #64 new
Former user created an issue

As seen in this screenshot, try-with-resources checks if a resource is null before closing it. Though there are no explicit checks for null, this gets flagged by BugPicker.

  33  public static boolean hasChildren(final Path path) throws IOException
  34  {
  35      try (DirectoryStream <Path> dirStream = Files.newDirectoryStream(path))
  36     {
  37          return dirStream.iterator().hasNext();
  38      }
  39  }

Unguarded local variable access (_ <: java.nio.file.DirectoryStream[@1;t=102]) though explicit test is done elsewhere.

location
fs.util. FsUtility { boolean hasChildren ( Path ) [ pc=8 line=37 ] } 
unguarded access
location
fs.util. FsUtility { boolean hasChildren ( Path ) [ pc=63 line=38 ] } 
guard

Comments (5)

  1. Log in to comment