Skip to content

Commit

Permalink
Attempt to fix #21075: NPE in getting primitives tag
Browse files Browse the repository at this point in the history
Signed-off-by: Taylor Smock <tsmock@fb.com>
  • Loading branch information
tsmock committed Jul 6, 2021
1 parent b56c170 commit 8497518
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public static Collection<VectorNode> decodeImageInfos(final JsonValue json, fina
* @return The MapillaryAbstractImage that was added/modified
*/
@Nullable
private static Pair<String, VectorNode> decodeImageInfo(@Nullable final JsonObject json,
private static synchronized Pair<String, VectorNode> decodeImageInfo(@Nullable final JsonObject json,
@Nullable final VectorDataSet data) {
if (json != null && data != null) {
final boolean useComputedData = Boolean.TRUE.equals(MapillaryProperties.USE_COMPUTED_LOCATIONS.get());
Expand Down Expand Up @@ -112,12 +112,11 @@ private static Pair<String, VectorNode> decodeImageInfo(@Nullable final JsonObje
}
TagMap map = image.getKeys();
// Clean up bad key value combinations
image.setKeys(null);
// Using for loop to (hopefully) fix JOSM #21070 and #21072
for (Tag tag : map.getTags()) {
if (tag.getKey() != null && tag.getValue() != null && !Utils.isStripEmpty(tag.getKey())
&& !Utils.isStripEmpty(tag.getValue())) {
image.put(tag);
// Tag#getKey and Tag#getValue are never null. According to docs.
if (Utils.isStripEmpty(tag.getKey()) || Utils.isStripEmpty(tag.getValue())) {
image.put(tag.getKey(), null);
}
}
final String sequence = MapillaryImageUtils.getSequenceKey(image);
Expand Down

0 comments on commit 8497518

Please sign in to comment.