Skip to content

Commit

Permalink
avoid concurrent mod exception
Browse files Browse the repository at this point in the history
  • Loading branch information
qqmyers committed Oct 8, 2024
1 parent dc12231 commit 033f1a7
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import edu.harvard.iq.dataverse.util.FileMetadataUtil;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
Expand Down Expand Up @@ -287,7 +288,7 @@ public Dataset execute(CommandContext ctxt) throws CommandException {
}
if ( theDataset != null ) {
final Dataset savedDataset=theDataset;
savedDataset.getLocks().stream()
new HashSet<>(savedDataset.getLocks()).stream()
.filter( l -> l.getReason() == DatasetLock.Reason.EditInProgress )
.forEach( existingLock -> {
existingLock = ctxt.em().merge(existingLock);
Expand All @@ -302,7 +303,11 @@ public Dataset execute(CommandContext ctxt) throws CommandException {
} finally {
// We're done making changes - remove the lock...
//Only happens if an exception has caused us to miss the lock removal in this transaction
ctxt.datasets().removeDatasetLocks(theDataset, DatasetLock.Reason.EditInProgress);
if(!theDataset.getLocks().isEmpty()) {
ctxt.datasets().removeDatasetLocks(theDataset, DatasetLock.Reason.EditInProgress);
} else {
logger.fine("No locks to remove");
}
}

return theDataset;
Expand Down

0 comments on commit 033f1a7

Please sign in to comment.