Index: trunk/src/org/openstreetmap/josm/gui/dialogs/properties/TagEditHelper.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/dialogs/properties/TagEditHelper.java	(revision 19084)
+++ trunk/src/org/openstreetmap/josm/gui/dialogs/properties/TagEditHelper.java	(revision 19085)
@@ -141,5 +141,5 @@
     /** The preference storage of recent tags */
     public static final ListProperty PROPERTY_RECENT_TAGS = new ListProperty("properties.recent-tags",
-            Collections.<String>emptyList());
+            Collections.emptyList());
     /** The preference list of tags which should not be remembered, since r9940 */
     public static final StringProperty PROPERTY_TAGS_TO_IGNORE = new StringProperty("properties.recent-tags.ignore",
@@ -181,5 +181,5 @@
     /**
      * Copy of recently added tags in sorted from newest to oldest order.
-     *
+     * <p>
      * We store the maximum number of recent tags to allow dynamic change of number of tags shown in the preferences.
      * Used to cache initial status.
@@ -278,25 +278,22 @@
         if (activeDataSet == null)
             return;
-        try {
-            activeDataSet.beginUpdate();
-            Collection<OsmPrimitive> selection = OsmDataManager.getInstance().getInProgressSelection();
-            this.sel = selection;
-            if (Utils.isEmpty(selection))
-                return;
-
-            final AddTagsDialog addDialog = getAddTagsDialog();
-
-            addDialog.showDialog();
-
-            addDialog.destroyActions();
+        final Collection<OsmPrimitive> selection = updateSelection();
+
+        if (Utils.isEmpty(selection))
+            return;
+
+        final AddTagsDialog addDialog = getAddTagsDialog();
+
+        addDialog.showDialog();
+
+        addDialog.destroyActions();
+        activeDataSet.update(() -> {
             // Remote control can cause the selection to change, see #23191.
-            if (addDialog.getValue() == 1 && (selection == sel || warnSelectionChanged())) {
+            if (addDialog.getValue() == 1 && (selection.equals(updateSelection()) || warnSelectionChanged())) {
                 addDialog.performTagAdding(selection);
             } else {
                 addDialog.undoAllTagsAdding();
             }
-        } finally {
-            activeDataSet.endUpdate();
-        }
+        });
     }
 
@@ -317,5 +314,5 @@
     public void editTag(final int row, boolean focusOnKey) {
         changedKey = null;
-        sel = OsmDataManager.getInstance().getInProgressSelection();
+        updateSelection();
         if (Utils.isEmpty(sel))
             return;
@@ -361,4 +358,19 @@
 
     /**
+     * Update the current selection for this editor
+     */
+    private Collection<OsmPrimitive> updateSelection() {
+        final DataSet activeDataSet = OsmDataManager.getInstance().getActiveDataSet();
+        try {
+            activeDataSet.getReadLock().lock();
+            Collection<OsmPrimitive> selection = new ArrayList<>(OsmDataManager.getInstance().getInProgressSelection());
+            this.sel = selection;
+            return selection;
+        } finally {
+            activeDataSet.getReadLock().unlock();
+        }
+    }
+
+    /**
      * For a given key k, return a list of keys which are used as keys for
      * auto-completing values to increase the search space.
@@ -370,5 +382,5 @@
             return Arrays.asList("addr:street", "name");
         else
-            return Arrays.asList(key);
+            return Collections.singletonList(key);
     }
 
@@ -552,5 +564,5 @@
             p.add(new JLabel(tr("Key")), GBC.std());
             p.add(Box.createHorizontalStrut(10), GBC.std());
-            p.add(keys, GBC.eol().fill(GBC.HORIZONTAL));
+            p.add(keys, GBC.eol().fill(GridBagConstraints.HORIZONTAL));
 
             List<AutoCompletionItem> valueList = autocomplete.getTagValues(getAutocompletionKeys(key), usedValuesAwareComparator);
@@ -569,5 +581,5 @@
             p.add(new JLabel(tr("Value")), GBC.std());
             p.add(Box.createHorizontalStrut(10), GBC.std());
-            p.add(values, GBC.eol().fill(GBC.HORIZONTAL));
+            p.add(values, GBC.eol().fill(GridBagConstraints.HORIZONTAL));
             p.add(Box.createVerticalStrut(2), GBC.eol());
 
@@ -829,5 +841,5 @@
             mainPanel.add(new JLabel("<html>"+trn("This will change up to {0} object.",
                 "This will change up to {0} objects.", sel.size(), sel.size())
-                +"<br><br>"+tr("Please select a key")), GBC.eol().fill(GBC.HORIZONTAL));
+                +"<br><br>"+tr("Please select a key")), GBC.eol().fill(GridBagConstraints.HORIZONTAL));
 
             keys = new AutoCompComboBox<>();
@@ -837,5 +849,5 @@
             keys.setAutocompleteEnabled(AUTOCOMPLETE_KEYS.get());
 
-            mainPanel.add(keys, GBC.eop().fill(GBC.HORIZONTAL));
+            mainPanel.add(keys, GBC.eop().fill(GridBagConstraints.HORIZONTAL));
             mainPanel.add(new JLabel(tr("Choose a value")), GBC.eol());
 
@@ -846,5 +858,5 @@
             values.setAutocompleteEnabled(AUTOCOMPLETE_VALUES.get());
 
-            mainPanel.add(values, GBC.eop().fill(GBC.HORIZONTAL));
+            mainPanel.add(values, GBC.eop().fill(GridBagConstraints.HORIZONTAL));
 
             cacheRecentTags();
@@ -978,7 +990,7 @@
                     lines.add(sc.getKeyText() + ' ' + tr("to apply first suggestion"))
             );
-            lines.add(Shortcut.getKeyText(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, KeyEvent.SHIFT_DOWN_MASK)) + ' '
+            lines.add(Shortcut.getKeyText(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.SHIFT_DOWN_MASK)) + ' '
                     +tr("to add without closing the dialog"));
-            Shortcut.findShortcut(KeyEvent.VK_1, commandDownMask | KeyEvent.SHIFT_DOWN_MASK).ifPresent(sc ->
+            Shortcut.findShortcut(KeyEvent.VK_1, commandDownMask | InputEvent.SHIFT_DOWN_MASK).ifPresent(sc ->
                     lines.add(sc.getKeyText() + ' ' + tr("to add first suggestion without closing the dialog"))
             );
@@ -1013,5 +1025,5 @@
                 recentTagsPanel = new JPanel(new GridBagLayout());
                 buildRecentTagsPanel();
-                mainPanel.add(recentTagsPanel, GBC.eol().fill(GBC.HORIZONTAL));
+                mainPanel.add(recentTagsPanel, GBC.eol().fill(GridBagConstraints.HORIZONTAL));
             } else {
                 Dimension panelOldSize = recentTagsPanel.getPreferredSize();
@@ -1132,5 +1144,5 @@
                 JPanel tagPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
                 tagPanel.add(tagLabel);
-                recentTagsPanel.add(tagPanel, GBC.eol().fill(GBC.HORIZONTAL));
+                recentTagsPanel.add(tagPanel, GBC.eol().fill(GridBagConstraints.HORIZONTAL));
             }
             // Clear label if no tags were added
