Changeset 18563 in josm for trunk/src


Ignore:
Timestamp:
2022-09-27T18:34:33+02:00 (2 years ago)
Author:
taylor.smock
Message:

Fix #22268: Upload of data triggering exception "Primitive cannot be modified in read-only dataset"

This occurs during upload, and appears to be a race condition where a dataset is
not locked when we check, but becomes locked while the relation copy constructor
is running.

This attempts to fix the problem by checking to see if any OsmDataLayer objects are
in the upload process.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/actions/IRelationEditorActionAccess.java

    r18433 r18563  
    66import org.openstreetmap.josm.data.osm.IRelation;
    77import org.openstreetmap.josm.data.osm.Relation;
     8import org.openstreetmap.josm.gui.MainApplication;
    89import org.openstreetmap.josm.gui.dialogs.relation.IRelationEditor;
    910import org.openstreetmap.josm.gui.dialogs.relation.MemberTable;
     
    1112import org.openstreetmap.josm.gui.dialogs.relation.SelectionTable;
    1213import org.openstreetmap.josm.gui.dialogs.relation.SelectionTableModel;
     14import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    1315import org.openstreetmap.josm.gui.tagging.TagEditorModel;
    1416import org.openstreetmap.josm.gui.tagging.ac.AutoCompletingTextField;
     
    7678        final Relation newRelation;
    7779        final Relation oldRelation = getEditor().getRelation();
    78         if (oldRelation != null && oldRelation.getDataSet() != null && oldRelation.getDataSet().isLocked()) {
     80        boolean isUploadInProgress = MainApplication.getLayerManager().getLayersOfType(OsmDataLayer.class)
     81                .stream().anyMatch(OsmDataLayer::isUploadInProgress);
     82        if (isUploadInProgress || oldRelation != null && oldRelation.getDataSet() != null && oldRelation.getDataSet().isLocked()) {
    7983            // If the dataset is locked, then we cannot change the relation. See JOSM #22024.
     84            // We should also avoid changing the relation if there is an upload in progress. See JOSM #22268/#22398.
     85            // There appears to be a race condition where a dataset might not be locked in the check, then is locked while using the
     86            // copy relation constructor.
    8087            // This is due to the `setMembers` -> `addReferrer` call chain requires that the dataset is not read only.
    8188            return oldRelation;
Note: See TracChangeset for help on using the changeset viewer.