Index: trunk/src/org/openstreetmap/josm/tools/Utils.java
===================================================================
--- trunk/src/org/openstreetmap/josm/tools/Utils.java	(revision 19132)
+++ trunk/src/org/openstreetmap/josm/tools/Utils.java	(revision 19133)
@@ -658,5 +658,5 @@
      *     How to Prevent Your Java Collections From Wasting Memory</a>
      */
-    @SuppressWarnings("unchecked")
+    @SuppressWarnings({"unchecked", "squid:S1696"})
     public static <K, V> Map<K, V> toUnmodifiableMap(Map<K, V> map) {
         if (isEmpty(map)) {
@@ -666,5 +666,11 @@
             return Collections.singletonMap(entry.getKey(), entry.getValue());
         }
-        // see #23748 don't use Map.ofEntries as it doesn't allow null keys or values
+        // see #23748: If the map contains `null`, then Map.ofEntries will throw an NPE.
+        // We also cannot check the map for `null`, since that may _also_ throw an NPE.
+        try {
+            return Map.ofEntries(map.entrySet().toArray(new Map.Entry[0]));
+        } catch (NullPointerException e) {
+            Logging.trace(e);
+        }
         return Collections.unmodifiableMap(map);
     }
