Changeset 19195 in josm for trunk/src/org


Ignore:
Timestamp:
2024-08-14T19:44:54+02:00 (5 months ago)
Author:
taylor.smock
Message:

Fix #23860: Duplicate key+value in preset causes an ISE in TagChecker

This fixes the actual issue in TagChecker, but also adds a sanity check to
TaggingPresetPreferenceTestIT since it is usually unintended to have
duplicate key/values (and it is always a problem if they are different and are
Key items).

The fix for TagChecker is just keeping whatever value is last. Not ideal, but
it should work 99% of the time since an object won't match the preset if we have
highway=footway and highway=footway2 as Key objects.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/validation/tests/TagChecker.java

    r19172 r19195  
    719719            Map<String, String> matchingTags = tp.data.stream()
    720720                    .filter(i -> Boolean.TRUE.equals(i.matches(tags)))
    721                     .filter(i -> i instanceof KeyedItem).map(i -> ((KeyedItem) i).key)
    722                     .collect(Collectors.toMap(k -> k, tags::get));
     721                    .filter(KeyedItem.class::isInstance).map(i -> ((KeyedItem) i).key)
     722                    .collect(Collectors.toMap(k -> k, tags::get, (o, n) -> n));
    723723            if (matchingPresetsOK.stream().noneMatch(
    724724                    tp2 -> matchingTags.entrySet().stream().allMatch(
Note: See TracChangeset for help on using the changeset viewer.