DS-3660: Fix discovery reindex on metadata change

Stored objects may get evicted from the session cache and get into detached
state. Lazy loaded fields are inaccessible and throw an exception on access.

Before using objects they have to be reloaded (retrieved from the
database and associated with the session again).
This commit is contained in:
Alexander Sulfrian
2017-08-02 16:26:26 +02:00
committed by Tim Donohue
parent 342f190231
commit 388558792c

View File

@@ -160,11 +160,12 @@ public class IndexEventConsumer implements Consumer {
if (objectsToUpdate != null && handlesToDelete != null) {
// update the changed Items not deleted because they were on create list
for (DSpaceObject iu : objectsToUpdate) {
for (DSpaceObject o : objectsToUpdate) {
/* we let all types through here and
* allow the search indexer to make
* decisions on indexing and/or removal
*/
DSpaceObject iu = ctx.reloadEntity(o);
String hdl = iu.getHandle();
if (hdl != null && !handlesToDelete.contains(hdl)) {
try {