Skip to content

FileLayerDeleter will throw NullPointerException #2011

Description

@lossyrob

Setup:

Have a File catalog in a state where a layer "exists", in that it has metadata in the attribute store, but the directory path pointed to by the FileLayerHeader.path for that layer does not exist.

Expected:

The FileLayerDeleter delete method will see that there's no file there, and move along exceptionless.

Actual:

It blows up with a null pointer exception with the following stack trace:

error] (run-main-0) java.lang.NullPointerException
java.lang.NullPointerException
        at scala.collection.mutable.ArrayOps$ofRef$.length$extension(ArrayOps.scala:192)
        at scala.collection.mutable.ArrayOps$ofRef.length(ArrayOps.scala:192)
        at scala.collection.IndexedSeqOptimized$class.foreach(IndexedSeqOptimized.scala:32)
        at scala.collection.mutable.ArrayOps$ofRef.foreach(ArrayOps.scala:186)
        at geotrellis.spark.io.file.FileLayerDeleter$$anon$1.delete(FileLayerDeleter.scala:36)
        at geotrellis.spark.io.file.FileLayerDeleter$$anon$1.delete(FileLayerDeleter.scala:16)
        at geotrellis.spark.io.file.FileLayerManager.delete(FileLayerManager.scala:20)

Problem code exists here:

val sourceLayerPath = new File(attributeStore.catalogPath, header.path)
sourceLayerPath
.listFiles()
.foreach(_.delete())
sourceLayerPath.delete
}

The issue should be fixed by checking sourceLayerPath exists before doing anything with it.

Thanks to @cepkoCC for the bug report.

Activity

  1. added this to the milestone on Feb 11, 2017
  2. cepkoCC commented on Feb 13, 2017

    @cepkoCC

    On it!

  3. modified the milestones: 1.1, on Mar 12, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions