Changeset 18006 in josm


Ignore:
Timestamp:
2021-07-12T13:33:02+02:00 (3 years ago)
Author:
Don-vip
Message:

fix NPE in TagMap constructor

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/osm/TagMap.java

    r16977 r18006  
    77import java.util.ArrayList;
    88import java.util.Arrays;
    9 import java.util.Collection;
    109import java.util.ConcurrentModificationException;
    1110import java.util.Iterator;
     
    7574            throw new UnsupportedOperationException();
    7675        }
    77 
    7876    }
    7977
     
    103101            return tags.length / 2;
    104102        }
    105 
    106103    }
    107104
     
    158155     * @since 10736
    159156     */
    160     public TagMap(Collection<Tag> tags) {
     157    public TagMap(Iterable<Tag> tags) {
     158        this.tags = EMPTY_TAGS;
    161159        for (Tag tag : tags) {
    162160            put(tag.getKey(), tag.getValue());
  • trunk/test/unit/org/openstreetmap/josm/data/osm/TagMapTest.java

    r17275 r18006  
    33
    44import static org.junit.jupiter.api.Assertions.assertEquals;
     5
     6import java.util.Arrays;
    57
    68import org.junit.jupiter.api.Test;
     
    1820        assertEquals("TagMap[]", new TagMap().toString());
    1921        assertEquals("TagMap[key=val]", new TagMap(new String[]{"key", "val"}).toString());
    20         assertEquals("TagMap[key=val,foo=bar]", new TagMap(new String[]{"key", "val", "foo", "bar"}).toString());
     22        TagMap foobar = new TagMap(new String[]{"key", "val", "foo", "bar"});
     23        assertEquals("TagMap[key=val,foo=bar]", foobar.toString());
     24        assertEquals("TagMap[key=val,foo=bar]", new TagMap(foobar).toString());
     25        TagCollection coll = new TagCollection(Arrays.asList(new Tag("a", "b")));
     26        assertEquals("TagMap[a=b]", new TagMap(coll).toString());
    2127    }
    2228}
Note: See TracChangeset for help on using the changeset viewer.