From 6c0d8ae241beeec4c12e5123c310a3c838b0bb1c Mon Sep 17 00:00:00 2001 From: Taylor Smock Date: Wed, 30 Oct 2019 08:35:43 -0600 Subject: [PATCH] Fix possible possible NPE with merging duplicate ways Signed-off-by: Taylor Smock --- .../josm/plugins/mapwithai/commands/MergeDuplicateWays.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/openstreetmap/josm/plugins/mapwithai/commands/MergeDuplicateWays.java b/src/main/java/org/openstreetmap/josm/plugins/mapwithai/commands/MergeDuplicateWays.java index 6ce1a6f..fb42cb8 100644 --- a/src/main/java/org/openstreetmap/josm/plugins/mapwithai/commands/MergeDuplicateWays.java +++ b/src/main/java/org/openstreetmap/josm/plugins/mapwithai/commands/MergeDuplicateWays.java @@ -66,6 +66,8 @@ public class MergeDuplicateWays extends Command { filterDataSet(getAffectedDataSet(), commands); } else if (way1 != null && way2 == null) { checkForDuplicateWays(way1, commands); + } else if (way1 == null) { + checkForDuplicateWays(way2, commands); } else { Command command = checkForDuplicateWays(way1, way2); if (command != null) { @@ -302,7 +304,7 @@ public class MergeDuplicateWays extends Command { final Node possDupeNode = way2.getNode(k); if (origNode.equals(possDupeNode) || origNode.getCoor().greatCircleDistance(possDupeNode.getCoor()) < MapWithAIPreferenceHelper - .getMaxNodeDistance()) { + .getMaxNodeDistance()) { final Pair origNodePair = new Pair<>(j, origNode); final Map dupeNodeMap = duplicateNodes.getOrDefault(origNodePair, new HashMap<>()); dupeNodeMap.put(k, possDupeNode);