Changeset 19133 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2024-07-09T15:50:36+02:00 (7 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/tools/Utils.java
r19124 r19133 658 658 * How to Prevent Your Java Collections From Wasting Memory</a> 659 659 */ 660 @SuppressWarnings("unchecked") 660 @SuppressWarnings({"unchecked", "squid:S1696"}) 661 661 public static <K, V> Map<K, V> toUnmodifiableMap(Map<K, V> map) { 662 662 if (isEmpty(map)) { … … 666 666 return Collections.singletonMap(entry.getKey(), entry.getValue()); 667 667 } 668 // see #23748 don't use Map.ofEntries as it doesn't allow null keys or values 668 // see #23748: If the map contains `null`, then Map.ofEntries will throw an NPE. 669 // We also cannot check the map for `null`, since that may _also_ throw an NPE. 670 try { 671 return Map.ofEntries(map.entrySet().toArray(new Map.Entry[0])); 672 } catch (NullPointerException e) { 673 Logging.trace(e); 674 } 669 675 return Collections.unmodifiableMap(map); 670 676 }
Note:
See TracChangeset
for help on using the changeset viewer.