Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,13 @@ public <E extends ReloadableEntity> void uncacheEntity(E entity) throws SQLExcep
} else if (entity instanceof Bundle) {
Bundle bundle = (Bundle) entity;

if (Hibernate.isInitialized(bundle.getBitstreams())) {
// Bundle.getBitstreams() creates a defensive copy via new ArrayList<>(bitstreams)
// which iterates the Hibernate proxy, triggering lazy loading unconditionally.
// Unlike Item.getBundles() which returns the raw proxy, we cannot safely call
// getBitstreams() when the bundle is detached from the session.
// Guard with session.contains(): if the bundle is still managed,
// lazy loading will work; if detached (e.g. after session.clear()), we skip.
if (getSession().contains(bundle)) {
for (Bitstream bitstream : Utils.emptyIfNull(bundle.getBitstreams())) {
uncacheEntity(bitstream);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@
import org.dspace.content.Community;
import org.dspace.content.MetadataValue;
import org.dspace.content.service.ItemService;
import org.dspace.core.LegacyPluginServiceImpl;
import org.dspace.ctask.testing.MarkerTask;
import org.dspace.eperson.EPerson;
import org.dspace.util.DSpaceConfigurationInitializer;
import org.dspace.util.DSpaceKernelInitializer;
import org.dspace.xmlworkflow.storedcomponents.XmlWorkflowItem;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;

Expand All @@ -46,6 +48,8 @@ public class WorkflowCurationIT
extends AbstractIntegrationTestWithDatabase {
@Inject
private ItemService itemService;
@Autowired
private LegacyPluginServiceImpl legacyPluginService;

/**
* Basic smoke test of a curation task attached to a workflow step.
Expand All @@ -57,6 +61,11 @@ public void curationTest()
throws Exception {
context.turnOffAuthorisationSystem();

// Reset the named plugin cache to avoid pollution from other tests
// (e.g. CreateMissingIdentifiersIT) that may have run before this one.
// See https://github.com/DSpace/DSpace/issues/8533
legacyPluginService.clearNamedPluginClasses();

//** GIVEN **

// A submitter;
Expand Down