Index: trunk/src/org/openstreetmap/josm/actions/OrthogonalizeAction.java
===================================================================
--- trunk/src/org/openstreetmap/josm/actions/OrthogonalizeAction.java	(revision 19105)
+++ trunk/src/org/openstreetmap/josm/actions/OrthogonalizeAction.java	(revision 19106)
@@ -44,5 +44,5 @@
 /**
  * Tools / Orthogonalize
- *
+ * <p>
  * Align edges of a way so all angles are angles of 90 or 180 degrees.
  * See USAGE String below.
@@ -73,5 +73,5 @@
      * excepted deviation from an angle of 0, 90, 180, 360 degrees
      * maximum value: 45 degrees
-     *
+     * <p>
      * Current policy is to except just everything, no matter how strange the result would be.
      */
@@ -86,8 +86,8 @@
     /**
      * Undo the previous orthogonalization for certain nodes.
-     *
+     * <p>
      * This is useful, if the way shares nodes that you don't like to change, e.g. imports or
      * work of another user.
-     *
+     * <p>
      * This action can be triggered by shortcut only.
      */
@@ -279,5 +279,6 @@
             int n = wd.wayNodes.size();
             int i = wd.wayNodes.indexOf(singleNode);
-            Node n0, n2;
+            final Node n0;
+            final Node n2;
             if (i == 0 && n >= 3 && singleNode.equals(wd.wayNodes.get(n-1))) {
                 n0 = wd.wayNodes.get(n-2);
@@ -428,5 +429,5 @@
                 for (Node n : cs) {
                     s.remove(n);
-                    average += nC.get(n).doubleValue();
+                    average += nC.get(n);
                 }
                 average = average / cs.size();
Index: trunk/src/org/openstreetmap/josm/gui/animation/DropImage.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/animation/DropImage.java	(revision 19105)
+++ trunk/src/org/openstreetmap/josm/gui/animation/DropImage.java	(revision 19106)
@@ -9,4 +9,5 @@
 import java.net.URL;
 import java.net.URLDecoder;
+import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
 import java.util.Enumeration;
@@ -71,5 +72,5 @@
             String path = "images/presets/";
             URL url = DropImage.class.getClassLoader().getResource(path);
-            if (url != null && url.getProtocol().equals("file")) {
+            if (url != null && "file".equals(url.getProtocol())) {
                 ArrayList<File> dirs = new ArrayList<>();
                 dirs.add(new File(url.toURI()));
@@ -87,7 +88,7 @@
                 } while (!dirs.isEmpty());
                 name = result.get(seed.nextInt(result.size()));
-            } else if (url != null && url.getProtocol().equals("jar")) {
-                String jarPath = url.getPath().substring(5, url.getPath().indexOf("!"));
-                try (JarFile jar = new JarFile(URLDecoder.decode(jarPath, "UTF-8"))) {
+            } else if (url != null && "jar".equals(url.getProtocol())) {
+                String jarPath = url.getPath().substring(5, url.getPath().indexOf('!'));
+                try (JarFile jar = new JarFile(URLDecoder.decode(jarPath, StandardCharsets.UTF_8))) {
                     Enumeration<JarEntry> entries = jar.entries();
                     while (entries.hasMoreElements()) {
Index: trunk/src/org/openstreetmap/josm/gui/conflict/pair/AbstractListMergeModel.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/conflict/pair/AbstractListMergeModel.java	(revision 19105)
+++ trunk/src/org/openstreetmap/josm/gui/conflict/pair/AbstractListMergeModel.java	(revision 19106)
@@ -65,5 +65,5 @@
  * decisions. {@link PropertyChangeListener}s can register for property value changes of
  * {@link #FROZEN_PROP}.
- *
+ * <p>
  * ListMergeModel is an abstract class. Three methods have to be implemented by subclasses:
  * <ul>
@@ -203,5 +203,5 @@
         entries = new EnumMap<>(ListRole.class);
         for (ListRole role : ListRole.values()) {
-            entries.put(role, new ArrayList<T>());
+            entries.put(role, new ArrayList<>());
         }
 
@@ -379,12 +379,11 @@
             items.add(tr("{0} more...", deletedIds.size() - MAX_DELETED_PRIMITIVE_IN_DIALOG));
         }
-        StringBuilder sb = new StringBuilder();
-        sb.append("<html>")
-          .append(tr("The following objects could not be copied to the target object<br>because they are deleted in the target dataset:"))
-          .append(Utils.joinAsHtmlUnorderedList(items))
-          .append("</html>");
+        String sb = "<html>" +
+                tr("The following objects could not be copied to the target object<br>because they are deleted in the target dataset:") +
+                Utils.joinAsHtmlUnorderedList(items) +
+                "</html>";
         HelpAwareOptionPane.showOptionDialog(
                 MainApplication.getMainFrame(),
-                sb.toString(),
+                sb,
                 tr("Merging deleted objects failed"),
                 JOptionPane.WARNING_MESSAGE,
Index: trunk/src/org/openstreetmap/josm/gui/conflict/tags/MultiValueCellEditor.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/conflict/tags/MultiValueCellEditor.java	(revision 19105)
+++ trunk/src/org/openstreetmap/josm/gui/conflict/tags/MultiValueCellEditor.java	(revision 19106)
@@ -28,9 +28,9 @@
  * proposed tag values. The editor also allows to select all proposed valued or
  * to remove the tag.
- *
+ * <p>
  * The editor responds intercepts some keys and interprets them as navigation keys. It
  * forwards navigation events to {@link NavigationListener}s registered with this editor.
  * You should register the parent table using this editor as {@link NavigationListener}.
- *
+ * <p>
  * {@link KeyEvent#VK_ENTER} and {@link KeyEvent#VK_TAB} trigger a {@link NavigationListener#gotoNextDecision()}.
  */
@@ -88,5 +88,5 @@
     public MultiValueCellEditor() {
         editorModel = new JosmComboBoxModel<>();
-        editor = new JosmComboBox<Object>(editorModel) {
+        editor = new JosmComboBox<>(editorModel) {
             @Override
             public void processKeyEvent(KeyEvent e) {
@@ -216,5 +216,6 @@
          */
         protected void renderValue(Object value) {
-            setFont(UIManager.getFont("ComboBox.font"));
+            final String comboBoxFont = "ComboBox.font";
+            setFont(UIManager.getFont(comboBoxFont));
             if (value instanceof String) {
                 setText((String) value);
@@ -223,17 +224,17 @@
                 case UNDECIDED:
                     setText(tr("Choose a value"));
-                    setFont(UIManager.getFont("ComboBox.font").deriveFont(Font.ITALIC + Font.BOLD));
+                    setFont(UIManager.getFont(comboBoxFont).deriveFont(Font.ITALIC + Font.BOLD));
                     break;
                 case KEEP_NONE:
                     setText(tr("none"));
-                    setFont(UIManager.getFont("ComboBox.font").deriveFont(Font.ITALIC + Font.BOLD));
+                    setFont(UIManager.getFont(comboBoxFont).deriveFont(Font.ITALIC + Font.BOLD));
                     break;
                 case KEEP_ALL:
                     setText(tr("all"));
-                    setFont(UIManager.getFont("ComboBox.font").deriveFont(Font.ITALIC + Font.BOLD));
+                    setFont(UIManager.getFont(comboBoxFont).deriveFont(Font.ITALIC + Font.BOLD));
                     break;
                 case SUM_ALL_NUMERIC:
                     setText(tr("sum"));
-                    setFont(UIManager.getFont("ComboBox.font").deriveFont(Font.ITALIC + Font.BOLD));
+                    setFont(UIManager.getFont(comboBoxFont).deriveFont(Font.ITALIC + Font.BOLD));
                     break;
                 default:
Index: trunk/src/org/openstreetmap/josm/gui/datatransfer/TagTransferable.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/datatransfer/TagTransferable.java	(revision 19105)
+++ trunk/src/org/openstreetmap/josm/gui/datatransfer/TagTransferable.java	(revision 19106)
@@ -54,7 +54,7 @@
                 string.append('\n');
             }
-            string.append(e.getKey());
-            string.append('=');
-            string.append(e.getValue());
+            string.append(e.getKey())
+                .append('=')
+                .append(e.getValue());
         }
         return string.toString();
Index: trunk/src/org/openstreetmap/josm/gui/dialogs/InspectPrimitiveDataText.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/dialogs/InspectPrimitiveDataText.java	(revision 19105)
+++ trunk/src/org/openstreetmap/josm/gui/dialogs/InspectPrimitiveDataText.java	(revision 19106)
@@ -223,6 +223,6 @@
             s.append(INDENT).append(INDENT);
             addHeadline(m.getMember());
-            s.append(tr(" as \"{0}\"", m.getRole()));
-            s.append(NL);
+            s.append(tr(" as \"{0}\"", m.getRole()))
+                .append(NL);
         }
     }
Index: trunk/src/org/openstreetmap/josm/gui/dialogs/SelectionListDialog.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/dialogs/SelectionListDialog.java	(revision 19105)
+++ trunk/src/org/openstreetmap/josm/gui/dialogs/SelectionListDialog.java	(revision 19106)
@@ -529,5 +529,5 @@
                     .filter(i -> history.get(i).equals(selection))
                     .findFirst()
-                    .ifPresent(i -> history.remove(i));
+                    .ifPresent(history::remove);
             int maxsize = Config.getPref().getInt("select.history-size", SELECTION_HISTORY_SIZE);
             while (history.size() > maxsize) {
Index: trunk/src/org/openstreetmap/josm/gui/dialogs/ToggleDialog.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/dialogs/ToggleDialog.java	(revision 19105)
+++ trunk/src/org/openstreetmap/josm/gui/dialogs/ToggleDialog.java	(revision 19106)
@@ -11,4 +11,5 @@
 import java.awt.Graphics;
 import java.awt.GraphicsEnvironment;
+import java.awt.GridBagConstraints;
 import java.awt.GridBagLayout;
 import java.awt.GridLayout;
@@ -46,4 +47,5 @@
 import javax.swing.JToggleButton;
 import javax.swing.Scrollable;
+import javax.swing.SwingConstants;
 import javax.swing.SwingUtilities;
 
@@ -100,23 +102,24 @@
      */
     public static final BooleanProperty PROP_DYNAMIC_BUTTONS = new BooleanProperty("dialog.dynamic.buttons", false);
+    private static final String SELECTED = "selected";
 
     private final transient ParametrizedEnumProperty<ButtonHidingType> propButtonHiding =
-            new ParametrizedEnumProperty<ToggleDialog.ButtonHidingType>(ButtonHidingType.class, ButtonHidingType.DYNAMIC) {
-        @Override
-        protected String getKey(String... params) {
-            return preferencePrefix + ".buttonhiding";
-        }
-
-        @Override
-        protected ButtonHidingType parse(String s) {
-            try {
-                return super.parse(s);
-            } catch (IllegalArgumentException e) {
-                // Legacy settings
-                Logging.trace(e);
-                return Boolean.parseBoolean(s) ? ButtonHidingType.DYNAMIC : ButtonHidingType.ALWAYS_SHOWN;
-            }
-        }
-    };
+            new ParametrizedEnumProperty<>(ButtonHidingType.class, ButtonHidingType.DYNAMIC) {
+                @Override
+                protected String getKey(String... params) {
+                    return preferencePrefix + ".buttonhiding";
+                }
+
+                @Override
+                protected ButtonHidingType parse(String s) {
+                    try {
+                        return super.parse(s);
+                    } catch (IllegalArgumentException e) {
+                        // Legacy settings
+                        Logging.trace(e);
+                        return Boolean.parseBoolean(s) ? ButtonHidingType.DYNAMIC : ButtonHidingType.ALWAYS_SHOWN;
+                    }
+                }
+            };
 
     /** The action to toggle this dialog */
@@ -354,6 +357,6 @@
             windowMenuItem.setState(true);
         }
-        toggleAction.putValue("selected", Boolean.FALSE);
-        toggleAction.putValue("selected", Boolean.TRUE);
+        toggleAction.putValue(SELECTED, Boolean.FALSE);
+        toggleAction.putValue(SELECTED, Boolean.TRUE);
     }
 
@@ -382,5 +385,5 @@
     @Override
     public void buttonHidden() {
-        if (Boolean.TRUE.equals(toggleAction.getValue("selected"))) {
+        if (Boolean.TRUE.equals(toggleAction.getValue(SELECTED))) {
             toggleAction.actionPerformed(null);
         }
@@ -402,5 +405,5 @@
         }
         setIsShowing(false);
-        toggleAction.putValue("selected", Boolean.FALSE);
+        toggleAction.putValue(SELECTED, Boolean.FALSE);
     }
 
@@ -551,5 +554,5 @@
             // scale down the dialog icon
             ImageIcon icon = ImageProvider.get("dialogs", iconName, ImageProvider.ImageSizes.SMALLICON);
-            lblTitle = new JLabel("", icon, JLabel.TRAILING);
+            lblTitle = new JLabel("", icon, SwingConstants.TRAILING);
             lblTitle.setIconTextGap(8);
 
@@ -569,5 +572,5 @@
             lblTitleWeak.setPreferredSize(new Dimension(Integer.MAX_VALUE, 20));
             lblTitleWeak.setMinimumSize(new Dimension(0, 20));
-            add(lblTitleWeak, GBC.std().fill(GBC.HORIZONTAL));
+            add(lblTitleWeak, GBC.std().fill(GridBagConstraints.HORIZONTAL));
 
             buttonsHide = new JButton(ImageProvider.get("misc", buttonHiding != ButtonHidingType.ALWAYS_SHOWN
Index: trunk/src/org/openstreetmap/josm/gui/dialogs/ValidatorDialog.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/dialogs/ValidatorDialog.java	(revision 19105)
+++ trunk/src/org/openstreetmap/josm/gui/dialogs/ValidatorDialog.java	(revision 19106)
@@ -176,5 +176,5 @@
         buttons.add(new SideButton(fixAction));
 
-        if (ValidatorPrefHelper.PREF_USE_IGNORE.get()) {
+        if (Boolean.TRUE.equals(ValidatorPrefHelper.PREF_USE_IGNORE.get())) {
             ignoreAction = new AbstractAction() {
                 {
@@ -430,5 +430,5 @@
         OsmDataLayer editLayer = e.getSource().getEditLayer();
         if (editLayer == null) {
-            tree.setErrorList(new ArrayList<TestError>());
+            tree.setErrorList(new ArrayList<>());
         } else {
             tree.setErrorList(editLayer.validationErrors);
Index: trunk/src/org/openstreetmap/josm/gui/dialogs/relation/MemberTransferHandler.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/dialogs/relation/MemberTransferHandler.java	(revision 19105)
+++ trunk/src/org/openstreetmap/josm/gui/dialogs/relation/MemberTransferHandler.java	(revision 19106)
@@ -101,5 +101,5 @@
         final RelationMemberTransferable.Data memberData = (RelationMemberTransferable.Data)
                 support.getTransferable().getTransferData(RelationMemberTransferable.RELATION_MEMBER_DATA);
-        importData(destination, insertRow, memberData.getRelationMemberData(), new AbstractRelationMemberConverter<RelationMemberData>() {
+        importData(destination, insertRow, memberData.getRelationMemberData(), new AbstractRelationMemberConverter<>() {
             @Override
             protected RelationMember getMember(MemberTable destination, RelationMemberData data, OsmPrimitive p) {
@@ -113,5 +113,5 @@
         final PrimitiveTransferData data = (PrimitiveTransferData)
                 support.getTransferable().getTransferData(PrimitiveTransferData.DATA_FLAVOR);
-        importData(destination, insertRow, data.getDirectlyAdded(), new AbstractRelationMemberConverter<PrimitiveData>() {
+        importData(destination, insertRow, data.getDirectlyAdded(), new AbstractRelationMemberConverter<>() {
             @Override
             protected RelationMember getMember(MemberTable destination, PrimitiveData data, OsmPrimitive p) {
Index: trunk/src/org/openstreetmap/josm/gui/download/BookmarkList.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/download/BookmarkList.java	(revision 19105)
+++ trunk/src/org/openstreetmap/josm/gui/download/BookmarkList.java	(revision 19106)
@@ -242,5 +242,5 @@
      */
     public BookmarkList() {
-        setModel(new DefaultListModel<Bookmark>());
+        setModel(new DefaultListModel<>());
         load();
         setVisibleRowCount(7);
Index: trunk/src/org/openstreetmap/josm/gui/download/OSMDownloadSource.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/download/OSMDownloadSource.java	(revision 19105)
+++ trunk/src/org/openstreetmap/josm/gui/download/OSMDownloadSource.java	(revision 19106)
@@ -110,5 +110,8 @@
                             bounds.extend(b);
                         }
-                    } catch (InterruptedException | ExecutionException ex) {
+                    } catch (InterruptedException ex) {
+                        Thread.currentThread().interrupt();
+                        Logging.warn(ex);
+                    } catch (ExecutionException ex) {
                         Logging.warn(ex);
                     }
@@ -215,5 +218,5 @@
             checkboxChangeListener = e -> {
                 rememberSettings();
-                dialog.getSelectedDownloadArea().ifPresent(OSMDownloadSourcePanel.this::boundingBoxChanged);
+                dialog.getSelectedDownloadArea().ifPresent(this::boundingBoxChanged);
             };
 
@@ -273,5 +276,5 @@
              * It is mandatory to specify the area to download from OSM.
              */
-            if (!settings.getDownloadBounds().isPresent()) {
+            if (settings.getDownloadBounds().isEmpty()) {
                 JOptionPane.showMessageDialog(
                         this.getParent(),
Index: trunk/src/org/openstreetmap/josm/gui/io/AbstractUploadTask.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/io/AbstractUploadTask.java	(revision 19105)
+++ trunk/src/org/openstreetmap/josm/gui/io/AbstractUploadTask.java	(revision 19106)
@@ -3,4 +3,5 @@
 
 import static org.openstreetmap.josm.gui.help.HelpUtil.ht;
+import static org.openstreetmap.josm.tools.I18n.marktr;
 import static org.openstreetmap.josm.tools.I18n.tr;
 
@@ -10,5 +11,4 @@
 import java.time.format.FormatStyle;
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
@@ -45,4 +45,7 @@
  */
 public abstract class AbstractUploadTask extends PleaseWaitRunnable {
+    private static final String CANCEL_TR = marktr("Cancel");
+    private static final String CANCEL = "cancel";
+    private static final String UPDATE_DATA = "updatedata";
 
     /**
@@ -132,13 +135,13 @@
                 new ButtonSpec(
                         lbl,
-                        new ImageProvider("updatedata"),
+                        new ImageProvider(UPDATE_DATA),
                         null, null),
                 new ButtonSpec(
                         tr("Synchronize entire dataset"),
-                        new ImageProvider("updatedata"),
+                        new ImageProvider(UPDATE_DATA),
                         null, null),
                 new ButtonSpec(
-                        tr("Cancel"),
-                        new ImageProvider("cancel"),
+                        tr(CANCEL_TR),
+                        new ImageProvider(CANCEL),
                         null, null)
         };
@@ -167,5 +170,5 @@
         case 0: synchronizePrimitive(primitiveType, id); break;
         case 1: synchronizeDataSet(); break;
-        default: return;
+        default: // Do nothing (just return)
         }
     }
@@ -180,9 +183,9 @@
                 new ButtonSpec(
                         tr("Synchronize entire dataset"),
-                        new ImageProvider("updatedata"),
+                        new ImageProvider(UPDATE_DATA),
                         null, null),
                 new ButtonSpec(
-                        tr("Cancel"),
-                        new ImageProvider("cancel"),
+                        tr(CANCEL_TR),
+                        new ImageProvider(CANCEL),
                         null, null)
         };
@@ -244,6 +247,6 @@
                 ),
                 new ButtonSpec(
-                        tr("Cancel"),
-                        new ImageProvider("cancel"),
+                        tr(CANCEL_TR),
+                        new ImageProvider(CANCEL),
                         tr("Click to cancel and to resume editing the map"),
                         null /* no specific help context */
@@ -267,5 +270,5 @@
             if (msg.contains("to delete")) {
                 DownloadReferrersAction.downloadReferrers(MainApplication.getLayerManager().getEditLayer(),
-                        Arrays.asList(conflict.a));
+                        Collections.singletonList(conflict.a));
             }
             if (msg.contains("to upload") && !conflict.b.isEmpty()) {
Index: trunk/src/org/openstreetmap/josm/gui/io/ChangesetManagementPanel.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/io/ChangesetManagementPanel.java	(revision 19105)
+++ trunk/src/org/openstreetmap/josm/gui/io/ChangesetManagementPanel.java	(revision 19106)
@@ -32,10 +32,11 @@
 import org.openstreetmap.josm.spi.preferences.Config;
 import org.openstreetmap.josm.tools.ImageProvider;
+import org.openstreetmap.josm.tools.Logging;
 
 /**
  * ChangesetManagementPanel allows to configure changeset to be used in the next upload.
- *
+ * <p>
  * It is displayed as one of the configuration panels in the {@link UploadDialog}.
- *
+ * <p>
  * ChangesetManagementPanel is a source for {@link java.beans.PropertyChangeEvent}s. Clients can listen to
  * <ul>
@@ -50,4 +51,5 @@
     static final String SELECTED_CHANGESET_PROP = ChangesetManagementPanel.class.getName() + ".selectedChangeset";
     static final String CLOSE_CHANGESET_AFTER_UPLOAD = ChangesetManagementPanel.class.getName() + ".closeChangesetAfterUpload";
+    private static final String UPLOAD_CHANGESET_CLOSE = "upload.changeset.close";
 
     private JosmComboBox<Changeset> cbOpenChangesets;
@@ -142,5 +144,5 @@
         cbOpenChangesets.addItemListener(closeChangesetAction);
 
-        cbCloseAfterUpload.setSelected(Config.getPref().getBoolean("upload.changeset.close", true));
+        cbCloseAfterUpload.setSelected(Config.getPref().getBoolean(UPLOAD_CHANGESET_CLOSE, true));
         cbCloseAfterUpload.addItemListener(new CloseAfterUploadItemStateListener());
 
@@ -198,9 +200,9 @@
             case ItemEvent.SELECTED:
                 firePropertyChange(CLOSE_CHANGESET_AFTER_UPLOAD, false, true);
-                Config.getPref().putBoolean("upload.changeset.close", true);
+                Config.getPref().putBoolean(UPLOAD_CHANGESET_CLOSE, true);
                 break;
             case ItemEvent.DESELECTED:
                 firePropertyChange(CLOSE_CHANGESET_AFTER_UPLOAD, true, false);
-                Config.getPref().putBoolean("upload.changeset.close", false);
+                Config.getPref().putBoolean(UPLOAD_CHANGESET_CLOSE, false);
                 break;
             default: // Do nothing
@@ -262,5 +264,5 @@
             ChangesetCache.getInstance().refreshChangesetsFromServer();
         } catch (OsmTransferException e) {
-            return;
+            Logging.trace(e);
         }
     }
Index: trunk/src/org/openstreetmap/josm/gui/io/UploadSelectionDialog.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/io/UploadSelectionDialog.java	(revision 19105)
+++ trunk/src/org/openstreetmap/josm/gui/io/UploadSelectionDialog.java	(revision 19106)
@@ -254,5 +254,5 @@
                 return Collections.emptyList();
             return Arrays.stream(indices).filter(i -> i >= 0)
-                    .mapToObj(i -> data.get(i))
+                    .mapToObj(data::get)
                     .collect(Collectors.toList());
         }
Index: trunk/src/org/openstreetmap/josm/gui/io/importexport/GpxExporter.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/io/importexport/GpxExporter.java	(revision 19105)
+++ trunk/src/org/openstreetmap/josm/gui/io/importexport/GpxExporter.java	(revision 19106)
@@ -4,4 +4,5 @@
 import static org.openstreetmap.josm.tools.I18n.tr;
 
+import java.awt.GridBagConstraints;
 import java.awt.GridBagLayout;
 import java.awt.event.ActionListener;
@@ -55,9 +56,10 @@
     private static final String GPL_WARNING = "<html><font color='red' size='-2'>"
         + tr("Note: GPL is not compatible with the OSM license. Do not upload GPL licensed tracks.") + "</html>";
+    private static final String PUBLIC_DOMAIN = "public domain";
 
     private static final String[] LICENSES = {
             "Creative Commons By-SA",
             "Open Database License (ODbL)",
-            "public domain",
+            PUBLIC_DOMAIN,
             "GNU Lesser Public License (LGPL)",
             "BSD License (MIT/X11)"};
@@ -65,8 +67,8 @@
     private static final String[] URLS = {
             "https://creativecommons.org/licenses/by-sa/3.0",
-            "http://opendatacommons.org/licenses/odbl/1.0",
-            "public domain",
+            "https://opendatacommons.org/licenses/odbl/1-0/",
+            PUBLIC_DOMAIN,
             "https://www.gnu.org/copyleft/lesser.html",
-            "http://www.opensource.org/licenses/bsd-license.php"};
+            "https://opensource.org/license/BSD-2-Clause"};
 
     /**
@@ -108,8 +110,7 @@
         if (quiet) {
             gpxData = getGpxData(layer, file);
-            try (OutputStream fo = Compression.getCompressedFileOutputStream(file)) {
-                GpxWriter w = new GpxWriter(fo);
+            try (OutputStream fo = Compression.getCompressedFileOutputStream(file);
+                 GpxWriter w = new GpxWriter(fo)) {
                 w.write(gpxData);
-                w.close();
                 fo.flush();
             }
@@ -135,5 +136,5 @@
         desc.setLineWrap(true);
         desc.setText(gpxData.getString(META_DESC));
-        p.add(new JScrollPane(desc), GBC.eop().fill(GBC.BOTH));
+        p.add(new JScrollPane(desc), GBC.eop().fill(GridBagConstraints.BOTH));
 
         JCheckBox author = new JCheckBox(tr("Add author information"), Config.getPref().getBoolean("lastAddAuthor", true));
@@ -143,5 +144,5 @@
         p.add(nameLabel, GBC.std().insets(10, 0, 5, 0));
         JosmTextField authorName = new JosmTextField();
-        p.add(authorName, GBC.eol().fill(GBC.HORIZONTAL));
+        p.add(authorName, GBC.eol().fill(GridBagConstraints.HORIZONTAL));
         nameLabel.setLabelFor(authorName);
 
@@ -149,5 +150,5 @@
         p.add(emailLabel, GBC.std().insets(10, 0, 5, 0));
         JosmTextField email = new JosmTextField();
-        p.add(email, GBC.eol().fill(GBC.HORIZONTAL));
+        p.add(email, GBC.eol().fill(GridBagConstraints.HORIZONTAL));
         emailLabel.setLabelFor(email);
 
@@ -155,5 +156,5 @@
         p.add(copyrightLabel, GBC.std().insets(10, 0, 5, 0));
         JosmTextField copyright = new JosmTextField();
-        p.add(copyright, GBC.std().fill(GBC.HORIZONTAL));
+        p.add(copyright, GBC.std().fill(GridBagConstraints.HORIZONTAL));
         copyrightLabel.setLabelFor(copyright);
 
@@ -164,9 +165,9 @@
         p.add(copyrightYearLabel, GBC.std().insets(10, 0, 5, 5));
         JosmTextField copyrightYear = new JosmTextField("");
-        p.add(copyrightYear, GBC.eol().fill(GBC.HORIZONTAL));
+        p.add(copyrightYear, GBC.eol().fill(GridBagConstraints.HORIZONTAL));
         copyrightYearLabel.setLabelFor(copyrightYear);
 
         JLabel warning = new JLabel("<html><font size='-2'>&nbsp;</html");
-        p.add(warning, GBC.eol().fill(GBC.HORIZONTAL).insets(15, 0, 0, 0));
+        p.add(warning, GBC.eol().fill(GridBagConstraints.HORIZONTAL).insets(15, 0, 0, 0));
         addDependencies(gpxData, author, authorName, email, copyright, predefined, copyrightYear, nameLabel, emailLabel,
                 copyrightLabel, copyrightYearLabel, warning);
@@ -175,13 +176,13 @@
         JosmTextField keywords = new JosmTextField();
         keywords.setText(gpxData.getString(META_KEYWORDS));
-        p.add(keywords, GBC.eol().fill(GBC.HORIZONTAL));
+        p.add(keywords, GBC.eol().fill(GridBagConstraints.HORIZONTAL));
 
         boolean sel = Config.getPref().getBoolean("gpx.export.colors", true);
         JCheckBox colors = new JCheckBox(tr("Save track colors in GPX file"), sel);
-        p.add(colors, GBC.eol().fill(GBC.HORIZONTAL));
+        p.add(colors, GBC.eol().fill(GridBagConstraints.HORIZONTAL));
         JCheckBox garmin = new JCheckBox(tr("Use Garmin compatible GPX extensions"),
                 Config.getPref().getBoolean("gpx.export.colors.garmin", false));
         garmin.setEnabled(sel);
-        p.add(garmin, GBC.eol().fill(GBC.HORIZONTAL).insets(20, 0, 0, 0));
+        p.add(garmin, GBC.eol().fill(GridBagConstraints.HORIZONTAL).insets(20, 0, 0, 0));
 
         boolean hasPrefs = !gpxData.getLayerPrefs().isEmpty();
@@ -189,5 +190,5 @@
                 hasPrefs && Config.getPref().getBoolean("gpx.export.prefs", true));
         layerPrefs.setEnabled(hasPrefs);
-        p.add(layerPrefs, GBC.eop().fill(GBC.HORIZONTAL));
+        p.add(layerPrefs, GBC.eop().fill(GridBagConstraints.HORIZONTAL));
 
         ExtendedDialog ed = new ExtendedDialog(MainApplication.getMainFrame(),
@@ -197,7 +198,5 @@
             .setContent(p);
 
-        colors.addActionListener(l -> {
-            garmin.setEnabled(colors.isSelected());
-        });
+        colors.addActionListener(l -> garmin.setEnabled(colors.isSelected()));
 
         garmin.addActionListener(l -> {
@@ -268,8 +267,7 @@
         }
 
-        try (OutputStream fo = Compression.getCompressedFileOutputStream(file)) {
-            GpxWriter w = new GpxWriter(fo);
+        try (OutputStream fo = Compression.getCompressedFileOutputStream(file);
+            GpxWriter w = new GpxWriter(fo)) {
             w.write(gpxData, cFormat, layerPrefs.isSelected());
-            w.close();
             fo.flush();
         }
@@ -409,5 +407,5 @@
             for (int i : l.getSelectedIndices()) {
                 if (i == 2) {
-                    license = new StringBuilder("public domain");
+                    license = new StringBuilder(PUBLIC_DOMAIN);
                     break;
                 }
Index: trunk/src/org/openstreetmap/josm/gui/layer/LayerManager.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/layer/LayerManager.java	(revision 19105)
+++ trunk/src/org/openstreetmap/josm/gui/layer/LayerManager.java	(revision 19106)
@@ -24,5 +24,5 @@
  * <h1>Threading</h1>
  * Synchronization of the layer manager is done by synchronizing all read/write access. All changes are internally done in the EDT thread.
- *
+ * <p>
  * Methods of this manager may be called from any thread in any order.
  * Listeners are called while this layer manager is locked, so they should not block on other threads.
@@ -189,8 +189,11 @@
     }
 
+    private static final String LISTENER = "listener";
+    private static final String EVENT = "event";
+
     /**
      * This is the list of layers we manage. The list is unmodifiable. That way, read access does
      * not need to be synchronized.
-     *
+     * <p>
      * It is only changed in the EDT.
      * @see LayerManager#updateLayers(Consumer)
@@ -255,5 +258,5 @@
     protected synchronized void realRemoveLayer(Layer layer) {
         GuiHelper.assertCallFromEdt();
-        Set<Layer> toRemove = Collections.newSetFromMap(new IdentityHashMap<Layer, Boolean>());
+        Set<Layer> toRemove = Collections.newSetFromMap(new IdentityHashMap<>());
         toRemove.add(layer);
 
@@ -361,5 +364,5 @@
     /**
      * Replies an unmodifiable list of layers of a certain type.
-     *
+     * <p>
      * Example:
      * <pre>
@@ -459,5 +462,5 @@
                 l.layerAdded(e);
             } catch (JosmRuntimeException | IllegalArgumentException | IllegalStateException t) {
-                throw BugReport.intercept(t).put("listener", l).put("event", e);
+                throw BugReport.intercept(t).put(LISTENER, l).put(EVENT, e);
             }
         }
@@ -476,5 +479,5 @@
                 l.layerRemoving(e);
             } catch (JosmRuntimeException | IllegalArgumentException | IllegalStateException t) {
-                throw BugReport.intercept(t).put("listener", l).put("event", e).put("layer", layer);
+                throw BugReport.intercept(t).put(LISTENER, l).put(EVENT, e).put("layer", layer);
             }
         }
@@ -492,5 +495,5 @@
                 l.layerOrderChanged(e);
             } catch (JosmRuntimeException | IllegalArgumentException | IllegalStateException t) {
-                throw BugReport.intercept(t).put("listener", l).put("event", e);
+                throw BugReport.intercept(t).put(LISTENER, l).put(EVENT, e);
             }
         }
Index: trunk/src/org/openstreetmap/josm/gui/layer/geoimage/SynchronizeTimeFromPhotoDialog.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/layer/geoimage/SynchronizeTimeFromPhotoDialog.java	(revision 19105)
+++ trunk/src/org/openstreetmap/josm/gui/layer/geoimage/SynchronizeTimeFromPhotoDialog.java	(revision 19106)
@@ -163,5 +163,5 @@
         JPanel panelLst = new JPanel(new BorderLayout());
 
-        JList<String> imgList = new JList<>(new AbstractListModel<String>() {
+        JList<String> imgList = new JList<>(new AbstractListModel<>() {
             @Override
             public String getElementAt(int i) {
Index: trunk/src/org/openstreetmap/josm/gui/layer/gpx/GpxDrawHelper.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/layer/gpx/GpxDrawHelper.java	(revision 19105)
+++ trunk/src/org/openstreetmap/josm/gui/layer/gpx/GpxDrawHelper.java	(revision 19106)
@@ -593,6 +593,6 @@
                     for (WayPoint trkPnt : segment) {
                         Object val = trkPnt.get(GpxConstants.PT_HDOP);
-                        if (val != null) {
-                            double hdop = ((Float) val).doubleValue();
+                        if (val instanceof Float) {
+                            double hdop = ((Float) val);
                             if (hdop > maxval) {
                                 maxval = hdop;
@@ -1466,5 +1466,6 @@
 
         // typical rendering rate -> use realtime preview instead of accurate display
-        final double maxSegm = 25_000, nrSegms = listSegm.size();
+        final double maxSegm = 25_000;
+        final double nrSegms = listSegm.size();
 
         // determine random drop rate
@@ -1511,6 +1512,8 @@
 
         // collect frequently used items
-        final long fromX = (long) fromPnt.getX(); final long deltaX = (long) (toPnt.getX() - fromX);
-        final long fromY = (long) fromPnt.getY(); final long deltaY = (long) (toPnt.getY() - fromY);
+        final long fromX = (long) fromPnt.getX();
+        final long fromY = (long) fromPnt.getY();
+        final long deltaX = (long) (toPnt.getX() - fromX);
+        final long deltaY = (long) (toPnt.getY() - fromY);
 
         // use same random values for each point
Index: trunk/src/org/openstreetmap/josm/gui/layer/imagery/TileSourceDisplaySettings.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/layer/imagery/TileSourceDisplaySettings.java	(revision 19105)
+++ trunk/src/org/openstreetmap/josm/gui/layer/imagery/TileSourceDisplaySettings.java	(revision 19106)
@@ -81,4 +81,5 @@
      * Create a new {@link TileSourceDisplaySettings}
      */
+    @SuppressWarnings("PMD.UnnecessaryVarargsArrayCreation") // See https://github.com/pmd/pmd/issues/5069
     public TileSourceDisplaySettings() {
         this(new String[] {PREFERENCE_PREFIX});
Index: trunk/src/org/openstreetmap/josm/gui/preferences/PreferenceTabbedPane.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/preferences/PreferenceTabbedPane.java	(revision 19105)
+++ trunk/src/org/openstreetmap/josm/gui/preferences/PreferenceTabbedPane.java	(revision 19106)
@@ -83,5 +83,4 @@
  * @author imi
  */
-@SuppressWarnings("deprecation")
 public final class PreferenceTabbedPane extends JTabbedPane implements ExpertModeChangeListener, ChangeListener {
 
@@ -118,7 +117,7 @@
             }
             if (requiresRestart) {
-                sb.append(tr("You have to restart JOSM for some settings to take effect."));
-                sb.append("<br/><br/>");
-                sb.append(tr("Would you like to restart now?"));
+                sb.append(tr("You have to restart JOSM for some settings to take effect."))
+                    .append("<br/><br/>")
+                    .append(tr("Would you like to restart now?"));
             }
             sb.append("</html>");
@@ -358,6 +357,6 @@
             selectTabBy(tps -> tps.equals(tab));
             return tab.selectSubTab(sub);
-        } catch (NoSuchElementException ignore) {
-            Logging.trace(ignore);
+        } catch (NoSuchElementException e) {
+            Logging.trace(e);
             return false;
         }
@@ -564,5 +563,6 @@
     private int computeMaxTabWidth() {
         FontMetrics fm = getFontMetrics(getFont());
-        return settings.stream().filter(x -> x instanceof TabPreferenceSetting).map(x -> ((TabPreferenceSetting) x).getTitle())
+        return settings.stream().filter(TabPreferenceSetting.class::isInstance)
+                .map(TabPreferenceSetting.class::cast).map(TabPreferenceSetting::getTitle)
                 .filter(Objects::nonNull).mapToInt(fm::stringWidth).max().orElse(120);
     }
Index: trunk/src/org/openstreetmap/josm/gui/preferences/ToolbarPreferences.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/preferences/ToolbarPreferences.java	(revision 19105)
+++ trunk/src/org/openstreetmap/josm/gui/preferences/ToolbarPreferences.java	(revision 19106)
@@ -859,9 +859,10 @@
             });
 
-            ListCellRenderer<ActionDefinition> renderer = new ListCellRenderer<ActionDefinition>() {
+            ListCellRenderer<ActionDefinition> renderer = new ListCellRenderer<>() {
                 private final DefaultListCellRenderer def = new DefaultListCellRenderer();
+
                 @Override
                 public Component getListCellRendererComponent(JList<? extends ActionDefinition> list,
-                        ActionDefinition action, int index, boolean isSelected, boolean cellHasFocus) {
+                                                              ActionDefinition action, int index, boolean isSelected, boolean cellHasFocus) {
                     String s;
                     Icon i;
Index: trunk/src/org/openstreetmap/josm/gui/preferences/imagery/CacheSettingsPanel.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/preferences/imagery/CacheSettingsPanel.java	(revision 19105)
+++ trunk/src/org/openstreetmap/josm/gui/preferences/imagery/CacheSettingsPanel.java	(revision 19106)
@@ -4,4 +4,5 @@
 import static org.openstreetmap.josm.tools.I18n.tr;
 
+import java.awt.GridBagConstraints;
 import java.awt.GridBagLayout;
 import java.awt.event.ActionEvent;
@@ -60,5 +61,5 @@
     private final JosmTextField cacheDir = new JosmTextField(11);
     private final JSpinner maxElementsOnDisk = new JSpinner(new SpinnerNumberModel(
-            AbstractCachedTileSourceLayer.MAX_DISK_CACHE_SIZE.get().intValue(), 0, Integer.MAX_VALUE, 1));
+            (int) AbstractCachedTileSourceLayer.MAX_DISK_CACHE_SIZE.get(), 0, Integer.MAX_VALUE, 1));
 
     /**
@@ -70,5 +71,5 @@
         add(new JLabel(tr("Tile cache directory: ")), GBC.std());
         add(GBC.glue(5, 0), GBC.std());
-        add(cacheDir, GBC.eol().fill(GBC.HORIZONTAL));
+        add(cacheDir, GBC.eol().fill(GridBagConstraints.HORIZONTAL));
 
         add(new JLabel(tr("Maximum size of disk cache (per imagery) in MB: ")), GBC.std());
@@ -94,5 +95,5 @@
                 GBC.eol().insets(5, 5, 0, 0));
             add(new JScrollPane(getTableForCache(cache, tableModel)),
-                GBC.eol().fill(GBC.BOTH));
+                GBC.eol().fill(GridBagConstraints.BOTH));
         });
     }
@@ -212,5 +213,7 @@
     private static boolean removeCacheFiles(String path, long maxSize) {
         File directory = new File(path);
-        File[] cacheFiles = directory.listFiles((dir, name) -> name.endsWith(".data") || name.endsWith(".key"));
+        final String data = ".data";
+        final String key = ".key";
+        File[] cacheFiles = directory.listFiles((dir, name) -> name.endsWith(data) || name.endsWith(key));
         boolean restartRequired = false;
         if (cacheFiles != null) {
@@ -223,8 +226,8 @@
                     Utils.deleteFile(cacheFile);
                     File otherFile = null;
-                    if (cacheFile.getName().endsWith(".data")) {
-                        otherFile = new File(cacheFile.getPath().replaceAll("\\.data$", ".key"));
-                    } else if (cacheFile.getName().endsWith(".key")) {
-                        otherFile = new File(cacheFile.getPath().replaceAll("\\.key$", ".data"));
+                    if (cacheFile.getName().endsWith(data)) {
+                        otherFile = new File(cacheFile.getPath().replaceAll("\\.data$", key));
+                    } else if (cacheFile.getName().endsWith(key)) {
+                        otherFile = new File(cacheFile.getPath().replaceAll("\\.key$", data));
                     }
                     if (otherFile != null) {
Index: trunk/src/org/openstreetmap/josm/gui/preferences/imagery/TMSSettingsPanel.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/preferences/imagery/TMSSettingsPanel.java	(revision 19105)
+++ trunk/src/org/openstreetmap/josm/gui/preferences/imagery/TMSSettingsPanel.java	(revision 19106)
@@ -49,7 +49,7 @@
                 TMSLayer.MAX_ZOOM, 1));
         maxConcurrentDownloads = new JSpinner(new SpinnerNumberModel(
-                TMSCachedTileLoader.THREAD_LIMIT.get().intValue(), 0, Integer.MAX_VALUE, 1));
+                (int) TMSCachedTileLoader.THREAD_LIMIT.get(), 0, Integer.MAX_VALUE, 1));
         maxDownloadsPerHost = new JSpinner(new SpinnerNumberModel(
-                TMSCachedTileLoader.HOST_LIMIT.get().intValue(), 0, Integer.MAX_VALUE, 1));
+                (int) TMSCachedTileLoader.HOST_LIMIT.get(), 0, Integer.MAX_VALUE, 1));
 
 
Index: trunk/src/org/openstreetmap/josm/gui/preferences/plugin/PluginPreference.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/preferences/plugin/PluginPreference.java	(revision 19105)
+++ trunk/src/org/openstreetmap/josm/gui/preferences/plugin/PluginPreference.java	(revision 19106)
@@ -3,4 +3,5 @@
 
 import static java.awt.GridBagConstraints.HORIZONTAL;
+import static org.openstreetmap.josm.tools.I18n.marktr;
 import static org.openstreetmap.josm.tools.I18n.tr;
 import static org.openstreetmap.josm.tools.I18n.trc;
@@ -71,4 +72,7 @@
  */
 public final class PluginPreference extends ExtensibleTabPreferenceSetting {
+    private static final String HTML_START = "<html>";
+    private static final String HTML_END = "</html>";
+    private static final String UPDATE_PLUGINS = marktr("Update plugins");
 
     /**
@@ -112,6 +116,6 @@
                     downloaded.size(),
                     downloaded.size()
-                    ));
-            sb.append("<ul>");
+                    ))
+                .append("<ul>");
             for (PluginInformation pi: downloaded) {
                 sb.append("<li>").append(pi.name).append(" (").append(pi.version).append(")</li>");
@@ -125,6 +129,6 @@
                     failed.size(),
                     failed.size()
-                    ));
-            sb.append("<ul>");
+                    ))
+                .append("<ul>");
             for (PluginInformation pi: failed) {
                 sb.append("<li>").append(pi.name).append("</li>");
@@ -149,14 +153,14 @@
         final Collection<PluginInformation> failed = task.getFailedPlugins();
         final StringBuilder sb = new StringBuilder();
-        sb.append("<html>")
+        sb.append(HTML_START)
           .append(buildDownloadSummary(task));
         if (restartRequired) {
             sb.append(tr("Please restart JOSM to activate the downloaded plugins."));
         }
-        sb.append("</html>");
+        sb.append(HTML_END);
         GuiHelper.runInEDTAndWait(() -> HelpAwareOptionPane.showOptionDialog(
                 parent,
                 sb.toString(),
-                tr("Update plugins"),
+                tr(UPDATE_PLUGINS),
                 !failed.isEmpty() ? JOptionPane.WARNING_MESSAGE : JOptionPane.INFORMATION_MESSAGE,
                         HelpUtil.ht("/Preferences/Plugins")
@@ -375,5 +379,5 @@
     class UpdateSelectedPluginsAction extends AbstractAction {
         UpdateSelectedPluginsAction() {
-            putValue(NAME, tr("Update plugins"));
+            putValue(NAME, tr(UPDATE_PLUGINS));
             putValue(SHORT_DESCRIPTION, tr("Update the selected plugins"));
             new ImageProvider("dialogs", "refresh").getResource().attachImageIcon(this);
@@ -388,6 +392,9 @@
                         JOptionPane.INFORMATION_MESSAGE,
                         null // FIXME: provide help context
-                        ));
-            } catch (InterruptedException | InvocationTargetException e) {
+                ));
+            } catch (InterruptedException e) {
+                Thread.currentThread().interrupt();
+                Logging.error(e);
+            } catch (InvocationTargetException e) {
                 Logging.error(e);
             }
@@ -401,5 +408,5 @@
                     pnlPluginPreferences,
                     toUpdate,
-                    tr("Update plugins")
+                    tr(UPDATE_PLUGINS)
                     );
             // the async task for downloading plugin information
@@ -444,5 +451,5 @@
                             // Time to find the missing plugins...
                             toAdd.addAll(pi.getRequiredPlugins().stream().filter(plugin -> PluginHandler.getPlugin(plugin) == null)
-                                    .map(plugin -> model.getPluginInformation(plugin))
+                                    .map(model::getPluginInformation)
                                     .collect(Collectors.toSet()));
                         }
@@ -502,8 +509,8 @@
             JCheckBox deleteNotInList = new JCheckBox(tr("Disable all other plugins"));
 
-            JLabel helpLabel = new JLabel("<html>" + String.join("<br/>",
+            JLabel helpLabel = new JLabel(HTML_START + String.join("<br/>",
                     tr("Enter a list of plugins you want to download."),
                     tr("You should add one plugin id per line, version information is ignored."),
-                    tr("You can copy+paste the list of a status report here.")) + "</html>");
+                    tr("You can copy+paste the list of a status report here.")) + HTML_END);
 
             if (JOptionPane.OK_OPTION == JOptionPane.showConfirmDialog(GuiHelper.getFrameForComponent(getTabPane()),
@@ -556,5 +563,5 @@
         private boolean confirmIgnoreNotFound(List<String> notFound) {
             String list = "<ul><li>" + String.join("</li><li>", notFound) + "</li></ul>";
-            String message = "<html>" + tr("The following plugins were not found. Continue anyway?") + list + "</html>";
+            String message = HTML_START + tr("The following plugins were not found. Continue anyway?") + list + HTML_END;
             return JOptionPane.showConfirmDialog(GuiHelper.getFrameForComponent(getTabPane()),
                     message) == JOptionPane.OK_OPTION;
Index: trunk/src/org/openstreetmap/josm/gui/tagging/ac/AutoCompComboBox.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/tagging/ac/AutoCompComboBox.java	(revision 19105)
+++ trunk/src/org/openstreetmap/josm/gui/tagging/ac/AutoCompComboBox.java	(revision 19106)
@@ -32,5 +32,5 @@
      */
     public AutoCompComboBox() {
-        this(new AutoCompComboBoxModel<E>());
+        this(new AutoCompComboBoxModel<>());
     }
 
@@ -42,5 +42,5 @@
     public AutoCompComboBox(AutoCompComboBoxModel<E> model) {
         super(model);
-        setEditor(new AutoCompComboBoxEditor<E>());
+        setEditor(new AutoCompComboBoxEditor<>());
         setEditable(true);
         getEditorComponent().setModel(model);
Index: trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPresetItemGuiSupport.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPresetItemGuiSupport.java	(revision 19105)
+++ trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPresetItemGuiSupport.java	(revision 19106)
@@ -135,5 +135,5 @@
         Tagged tagged = Tagged.ofMap(selected.iterator().next().getKeys());
         // update changed tags
-        changedTagsSupplier.get().forEach(tag -> tagged.put(tag));
+        changedTagsSupplier.get().forEach(tagged::put);
         return tagged;
     }
Index: trunk/src/org/openstreetmap/josm/io/GpxWriter.java
===================================================================
--- trunk/src/org/openstreetmap/josm/io/GpxWriter.java	(revision 19105)
+++ trunk/src/org/openstreetmap/josm/io/GpxWriter.java	(revision 19106)
@@ -147,5 +147,5 @@
                 .collect(Collectors.toList());
 
-        validprefixes = namespaces.stream().map(n -> n.getPrefix()).collect(Collectors.toList());
+        validprefixes = namespaces.stream().map(XMLNamespace::getPrefix).collect(Collectors.toList());
 
         data.creator = JOSM_CREATOR_NAME;
Index: trunk/src/org/openstreetmap/josm/io/MaxChangesetSizeExceededPolicy.java
===================================================================
--- trunk/src/org/openstreetmap/josm/io/MaxChangesetSizeExceededPolicy.java	(revision 19105)
+++ trunk/src/org/openstreetmap/josm/io/MaxChangesetSizeExceededPolicy.java	(revision 19106)
@@ -6,4 +6,5 @@
  * @since 12687 (moved from {@code gui.io} package)
  */
+@SuppressWarnings("PMD.LongVariable")
 public enum MaxChangesetSizeExceededPolicy {
     /**
Index: trunk/src/org/openstreetmap/josm/io/MultiFetchServerObjectReader.java
===================================================================
--- trunk/src/org/openstreetmap/josm/io/MultiFetchServerObjectReader.java	(revision 19105)
+++ trunk/src/org/openstreetmap/josm/io/MultiFetchServerObjectReader.java	(revision 19106)
@@ -357,5 +357,5 @@
                 Logging.error(e);
                 if (e.getCause() instanceof OsmTransferException)
-                    throw (OsmTransferException) e.getCause();
+                    throw (OsmTransferException) e.getCause(); // NOPMD
             }
         }
Index: trunk/src/org/openstreetmap/josm/io/OsmPbfReader.java
===================================================================
--- trunk/src/org/openstreetmap/josm/io/OsmPbfReader.java	(revision 19105)
+++ trunk/src/org/openstreetmap/josm/io/OsmPbfReader.java	(revision 19106)
@@ -7,5 +7,4 @@
 import java.io.IOException;
 import java.io.InputStream;
-import java.io.OutputStream;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -68,6 +67,18 @@
         @Override
         public int read() throws IOException {
-            count++;
-            return this.source.read();
+            final int read = this.source.read();
+            if (read > 0) {
+                count++;
+            }
+            return read;
+        }
+
+        @Override
+        public int read(@Nonnull byte[] b, int off, int len) throws IOException {
+            final int read = this.source.read(b, off, len);
+            if (read > 0) {
+                this.count += read;
+            }
+            return read;
         }
 
@@ -104,9 +115,4 @@
         public boolean markSupported() {
             return this.source.markSupported();
-        }
-
-        @Override
-        public long transferTo(OutputStream out) throws IOException {
-            return super.transferTo(out);
         }
 
@@ -251,39 +257,39 @@
         int size = Integer.MIN_VALUE;
         Blob.CompressionType type = null;
-        ProtobufRecord current;
         // Needed since size and compression type + compression data may be in a different order
         byte[] bytes = null;
         while (parser.hasNext() && cis.getCount() - start < header.dataSize()) {
-            current = new ProtobufRecord(baos, parser);
-            switch (current.getField()) {
-                case 1:
-                    type = Blob.CompressionType.raw;
-                    bytes = current.getBytes();
-                    break;
-                case 2:
-                    size = current.asUnsignedVarInt().intValue();
-                    break;
-                case 3:
-                    type = Blob.CompressionType.zlib;
-                    bytes = current.getBytes();
-                    break;
-                case 4:
-                    type = Blob.CompressionType.lzma;
-                    bytes = current.getBytes();
-                    break;
-                case 5:
-                    type = Blob.CompressionType.bzip2;
-                    bytes = current.getBytes();
-                    break;
-                case 6:
-                    type = Blob.CompressionType.lz4;
-                    bytes = current.getBytes();
-                    break;
-                case 7:
-                    type = Blob.CompressionType.zstd;
-                    bytes = current.getBytes();
-                    break;
-                default:
-                    throw new IllegalStateException("Unknown compression type: " + current.getField());
+            try (ProtobufRecord current = new ProtobufRecord(baos, parser)) {
+                switch (current.getField()) {
+                    case 1:
+                        type = Blob.CompressionType.raw;
+                        bytes = current.getBytes();
+                        break;
+                    case 2:
+                        size = current.asUnsignedVarInt().intValue();
+                        break;
+                    case 3:
+                        type = Blob.CompressionType.zlib;
+                        bytes = current.getBytes();
+                        break;
+                    case 4:
+                        type = Blob.CompressionType.lzma;
+                        bytes = current.getBytes();
+                        break;
+                    case 5:
+                        type = Blob.CompressionType.bzip2;
+                        bytes = current.getBytes();
+                        break;
+                    case 6:
+                        type = Blob.CompressionType.lz4;
+                        bytes = current.getBytes();
+                        break;
+                    case 7:
+                        type = Blob.CompressionType.zstd;
+                        bytes = current.getBytes();
+                        break;
+                    default:
+                        throw new IllegalStateException("Unknown compression type: " + current.getField());
+                }
             }
         }
@@ -421,5 +427,5 @@
         }
         for (ProtobufRecord primitiveGroup : primitiveGroups) {
-            try {
+            try (primitiveGroup) {
                 ds.beginUpdate();
                 parsePrimitiveGroup(baos, primitiveGroup.getBytes(), primitiveBlockRecord);
Index: trunk/src/org/openstreetmap/josm/io/session/GpxTracksSessionExporter.java
===================================================================
--- trunk/src/org/openstreetmap/josm/io/session/GpxTracksSessionExporter.java	(revision 19105)
+++ trunk/src/org/openstreetmap/josm/io/session/GpxTracksSessionExporter.java	(revision 19106)
@@ -79,5 +79,6 @@
 
     @Override
-    @SuppressWarnings("resource")
+    // The new closable resources in this method will close the input OutputStream
+    @SuppressWarnings({"squid:S2095", "PMD.CloseResource"})
     protected void addDataFile(OutputStream out) {
         Writer writer = new OutputStreamWriter(out, StandardCharsets.UTF_8);
Index: trunk/src/org/openstreetmap/josm/io/session/MarkerSessionExporter.java
===================================================================
--- trunk/src/org/openstreetmap/josm/io/session/MarkerSessionExporter.java	(revision 19105)
+++ trunk/src/org/openstreetmap/josm/io/session/MarkerSessionExporter.java	(revision 19106)
@@ -3,4 +3,5 @@
 
 import java.awt.Component;
+import java.awt.GridBagConstraints;
 import java.awt.GridBagLayout;
 import java.io.IOException;
@@ -18,4 +19,5 @@
 import javax.swing.SwingConstants;
 
+import org.openstreetmap.josm.data.gpx.GpxConstants;
 import org.openstreetmap.josm.data.gpx.GpxData;
 import org.openstreetmap.josm.gui.MainApplication;
@@ -66,5 +68,5 @@
         p.add(export, GBC.std());
         p.add(lbl, GBC.std());
-        p.add(GBC.glue(1, 0), GBC.std().fill(GBC.HORIZONTAL));
+        p.add(GBC.glue(1, 0), GBC.std().fill(GridBagConstraints.HORIZONTAL));
         return p;
     }
@@ -93,5 +95,6 @@
     }
 
-    @SuppressWarnings("resource")
+    // The new closable resources in this method will close the input OutputStream
+    @SuppressWarnings({"squid:S2095", "PMD.CloseResource"})
     protected void addDataFile(OutputStream out) {
         Writer writer = new OutputStreamWriter(out, StandardCharsets.UTF_8);
@@ -132,5 +135,5 @@
                 }
             });
-            data.put(GpxData.META_DESC, "exported JOSM marker layer");
+            data.put(GpxConstants.META_DESC, "exported JOSM marker layer");
             for (Marker m : layer.data) {
                 data.waypoints.add(m.convertToWayPoint());
Index: trunk/src/org/openstreetmap/josm/plugins/PluginClassLoader.java
===================================================================
--- trunk/src/org/openstreetmap/josm/plugins/PluginClassLoader.java	(revision 19105)
+++ trunk/src/org/openstreetmap/josm/plugins/PluginClassLoader.java	(revision 19106)
@@ -59,15 +59,5 @@
         Class<?> result = findLoadedClass(name);
         if (result == null) {
-            for (PluginClassLoader dep : dependencies) {
-                try {
-                    result = dep.loadClass(name, resolve);
-                    if (result != null) {
-                        return result;
-                    }
-                } catch (ClassNotFoundException e) {
-                    Logging.trace("Plugin class not found in dep {0}: {1}", dep, e.getMessage());
-                    Logging.trace(e);
-                }
-            }
+            result = findClassInDependencies(name, resolve);
             try {
                 // Will delegate to parent.loadClass(name, resolve) if needed
@@ -93,5 +83,28 @@
     }
 
+    /**
+     * Try to find the specified class in this classes dependencies
+     * @param name The name of the class to find
+     * @param resolve {@code true} to resolve the class
+     * @return the class, if found, otherwise {@code null}
+     */
+    @SuppressWarnings("PMD.CloseResource") // NOSONAR We do *not* want to close class loaders in this method...
+    private Class<?> findClassInDependencies(String name, boolean resolve) {
+        for (PluginClassLoader dep : dependencies) {
+            try {
+                Class<?> result = dep.loadClass(name, resolve);
+                if (result != null) {
+                    return result;
+                }
+            } catch (ClassNotFoundException e) {
+                Logging.trace("Plugin class not found in dep {0}: {1}", dep, e.getMessage());
+                Logging.trace(e);
+            }
+        }
+        return null;
+    }
+
     @Override
+    @SuppressWarnings("PMD.CloseResource") // NOSONAR We do *not* want to close class loaders in this method...
     public URL findResource(String name) {
         URL resource = super.findResource(name);
Index: trunk/src/org/openstreetmap/josm/plugins/PluginHandler.java
===================================================================
--- trunk/src/org/openstreetmap/josm/plugins/PluginHandler.java	(revision 19105)
+++ trunk/src/org/openstreetmap/josm/plugins/PluginHandler.java	(revision 19106)
@@ -56,4 +56,5 @@
 import javax.swing.UIManager;
 
+import jakarta.annotation.Nullable;
 import org.openstreetmap.josm.actions.RestartAction;
 import org.openstreetmap.josm.data.Preferences;
@@ -770,20 +771,6 @@
 
         // make sure the dependencies to other plugins are not broken
-        //
         if (requires != null) {
-            Set<String> pluginNames = new HashSet<>();
-            for (PluginInformation pi: plugins) {
-                pluginNames.add(pi.name);
-                if (pi.provides != null) {
-                    pluginNames.add(pi.provides);
-                }
-            }
-            Set<String> missingPlugins = new HashSet<>();
-            List<String> requiredPlugins = local ? plugin.getLocalRequiredPlugins() : plugin.getRequiredPlugins();
-            for (String requiredPlugin : requiredPlugins) {
-                if (!pluginNames.contains(requiredPlugin)) {
-                    missingPlugins.add(requiredPlugin);
-                }
-            }
+            Set<String> missingPlugins = findMissingPlugins(plugins, plugin, local);
             if (!missingPlugins.isEmpty()) {
                 if (parent != null) {
@@ -794,4 +781,29 @@
         }
         return true;
+    }
+
+    /**
+     * Find the missing plugin(s) for a specified plugin
+     * @param plugins The currently loaded plugins
+     * @param plugin The plugin to find the missing information for
+     * @param local Determines if the local or up-to-date plugin dependencies are to be checked.
+     * @return A set of missing plugins for the given plugin
+     */
+    private static Set<String> findMissingPlugins(Collection<PluginInformation> plugins, PluginInformation plugin, boolean local) {
+        Set<String> pluginNames = new HashSet<>();
+        for (PluginInformation pi: plugins) {
+            pluginNames.add(pi.name);
+            if (pi.provides != null) {
+                pluginNames.add(pi.provides);
+            }
+        }
+        Set<String> missingPlugins = new HashSet<>();
+        List<String> requiredPlugins = local ? plugin.getLocalRequiredPlugins() : plugin.getRequiredPlugins();
+        for (String requiredPlugin : requiredPlugins) {
+            if (!pluginNames.contains(requiredPlugin)) {
+                missingPlugins.add(requiredPlugin);
+            }
+        }
+        return missingPlugins;
     }
 
@@ -818,4 +830,5 @@
      * @param plugins the plugins to add
      */
+    @SuppressWarnings("PMD.CloseResource") // NOSONAR We do *not* want to close class loaders in this method...
     private static void extendJoinedPluginResourceCL(Collection<PluginInformation> plugins) {
         // iterate all plugins and collect all libraries of all plugins:
@@ -901,33 +914,8 @@
                 return;
 
-            for (PluginInformation info : toLoad) {
-                PluginClassLoader cl = AccessController.doPrivileged((PrivilegedAction<PluginClassLoader>)
-                    () -> new PluginClassLoader(
-                        info.libraries.toArray(new URL[0]),
-                        PluginHandler.class.getClassLoader(),
-                        null));
-                classLoaders.put(info.name, cl);
-            }
+            generateClassloaders(toLoad);
 
             // resolve dependencies
-            for (PluginInformation info : toLoad) {
-                PluginClassLoader cl = classLoaders.get(info.name);
-                DEPENDENCIES:
-                for (String depName : info.getLocalRequiredPlugins()) {
-                    for (PluginInformation depInfo : toLoad) {
-                        if (isDependency(depInfo, depName)) {
-                            cl.addDependency(classLoaders.get(depInfo.name));
-                            continue DEPENDENCIES;
-                        }
-                    }
-                    for (PluginProxy proxy : pluginList) {
-                        if (isDependency(proxy.getPluginInformation(), depName)) {
-                            cl.addDependency(proxy.getClassLoader());
-                            continue DEPENDENCIES;
-                        }
-                    }
-                    Logging.error("unable to find dependency " + depName + " for plugin " + info.getName());
-                }
-            }
+            resolveDependencies(toLoad);
 
             extendJoinedPluginResourceCL(toLoad);
@@ -944,4 +932,51 @@
     }
 
+    /**
+     * Generate classloaders for a list of plugins
+     * @param toLoad The plugins to generate the classloaders for
+     */
+    @SuppressWarnings({"squid:S2095", "PMD.CloseResource"}) // NOSONAR the classloaders and put in a map which we want to keep.
+    private static void generateClassloaders(List<PluginInformation> toLoad) {
+        for (PluginInformation info : toLoad) {
+            PluginClassLoader cl = AccessController.doPrivileged((PrivilegedAction<PluginClassLoader>)
+                    () -> new PluginClassLoader(
+                            info.libraries.toArray(new URL[0]),
+                            PluginHandler.class.getClassLoader(),
+                            null));
+            classLoaders.put(info.name, cl);
+        }
+    }
+
+    /**
+     * Resolve dependencies for a list of plugins
+     * @param toLoad The plugins to resolve dependencies for
+     */
+    @SuppressWarnings({"squid:S2095", "PMD.CloseResource"}) // NOSONAR the classloaders are from a persistent map
+    private static void resolveDependencies(List<PluginInformation> toLoad) {
+        for (PluginInformation info : toLoad) {
+            PluginClassLoader cl = classLoaders.get(info.name);
+            for (String depName : info.getLocalRequiredPlugins()) {
+                boolean finished = false;
+                for (PluginInformation depInfo : toLoad) {
+                    if (isDependency(depInfo, depName)) {
+                        cl.addDependency(classLoaders.get(depInfo.name));
+                        finished = true;
+                        break;
+                    }
+                }
+                if (finished) {
+                    continue;
+                }
+                for (PluginProxy proxy : pluginList) {
+                    if (isDependency(proxy.getPluginInformation(), depName)) {
+                        cl.addDependency(proxy.getClassLoader());
+                        break;
+                    }
+                }
+                Logging.error("unable to find dependency " + depName + " for plugin " + info.getName());
+            }
+        }
+    }
+
     private static boolean isDependency(PluginInformation pi, String depName) {
         return depName.equals(pi.getName()) || depName.equals(pi.provides);
@@ -999,4 +1034,6 @@
      *
      */
+    @Nullable
+    @SuppressWarnings("squid:S1168") // The null return is part of the API for this method.
     private static Map<String, PluginInformation> loadLocallyAvailablePluginInformation(ProgressMonitor monitor) {
         if (monitor == null) {
@@ -1012,4 +1049,5 @@
                 return null;
             } catch (InterruptedException e) {
+                Thread.currentThread().interrupt();
                 Logging.warn("InterruptedException in " + PluginHandler.class.getSimpleName()
                         + " while loading locally available plugin information");
@@ -1027,17 +1065,16 @@
 
     private static void alertMissingPluginInformation(Component parent, Collection<String> plugins) {
-        StringBuilder sb = new StringBuilder();
-        sb.append(HTML_START)
-          .append(trn("JOSM could not find information about the following plugin:",
-                "JOSM could not find information about the following plugins:",
-                plugins.size()))
-          .append(Utils.joinAsHtmlUnorderedList(plugins))
-          .append(trn("The plugin is not going to be loaded.",
-                "The plugins are not going to be loaded.",
-                plugins.size()))
-          .append(HTML_END);
+        String sb = HTML_START +
+                trn("JOSM could not find information about the following plugin:",
+                        "JOSM could not find information about the following plugins:",
+                        plugins.size()) +
+                Utils.joinAsHtmlUnorderedList(plugins) +
+                trn("The plugin is not going to be loaded.",
+                        "The plugins are not going to be loaded.",
+                        plugins.size()) +
+                HTML_END;
         HelpAwareOptionPane.showOptionDialog(
                 parent,
-                sb.toString(),
+                sb,
                 tr(WARNING),
                 JOptionPane.WARNING_MESSAGE,
@@ -1191,4 +1228,5 @@
                 // don't abort in case of error, continue with downloading plugins below
             } catch (InterruptedException e) {
+                Thread.currentThread().interrupt();
                 Logging.warn(tr("Failed to download plugin information list") + ": InterruptedException");
                 // don't abort in case of error, continue with downloading plugins below
@@ -1240,4 +1278,5 @@
                     return plugins;
                 } catch (InterruptedException e) {
+                    Thread.currentThread().interrupt();
                     Logging.warn("InterruptedException in " + PluginHandler.class.getSimpleName()
                             + " while updating plugins");
@@ -1535,5 +1574,8 @@
             GuiHelper.runInEDT(task);
             return task.get();
-        } catch (InterruptedException | ExecutionException e) {
+        } catch (InterruptedException e) {
+            Thread.currentThread().interrupt();
+            Logging.warn(e);
+        } catch (ExecutionException e) {
             Logging.warn(e);
         }
Index: trunk/src/org/openstreetmap/josm/spi/lifecycle/Lifecycle.java
===================================================================
--- trunk/src/org/openstreetmap/josm/spi/lifecycle/Lifecycle.java	(revision 19105)
+++ trunk/src/org/openstreetmap/josm/spi/lifecycle/Lifecycle.java	(revision 19106)
@@ -67,4 +67,6 @@
      * @since 14139
      */
+    // PMD wasn't detecting that we were trying to shutdown the ExecutorService
+    @SuppressWarnings("PMD.CloseResource")
     public static void initialize(InitializationSequence initSequence) {
         // Initializes tasks that must be run before parallel tasks
@@ -90,5 +92,8 @@
                 Logging.log(Logging.LEVEL_ERROR, "Unable to shutdown executor service", e);
             }
-        } catch (InterruptedException | ExecutionException ex) {
+        } catch (InterruptedException ex) {
+            Thread.currentThread().interrupt();
+            throw new JosmRuntimeException(ex);
+        } catch (ExecutionException ex) {
             throw new JosmRuntimeException(ex);
         }
