datadryad/dryad-repo — pull request #396 by dleehr (2013-10-18 20:59:14+00:00)
Title: Fix getValidity() NullPointerExceptions by clearing out dataFiles list

NullPointerExceptions that appear when viewing a data file page after a data package page.

ItemViewers are recycled by dspace between requests. ItemViewer objects have an ArrayList of dataFiles that are populated when viewing a package. This list was populated when viewing a data package but left alone when viewing a file, so it was very likely to contain data files after a user navigates from a data package page to a data file page.

The files contained in the list hold a reference to the context where they were loaded. The context is usually completed after the data package page is shown, so the files were holding a reference to a completed context (null connection)

When getValidity() ran to get the validity of the data file page, it tried to pass in the files from the array, which have stale contexts and can't be used without triggering an exception.

Clearing out dataFiles in recycle() fixes this issue