Index: src/org/openstreetmap/josm/data/validation/tests/ConnectivityRelations.java
===================================================================
--- src/org/openstreetmap/josm/data/validation/tests/ConnectivityRelations.java	(revision 19413)
+++ src/org/openstreetmap/josm/data/validation/tests/ConnectivityRelations.java	(working copy)
@@ -169,6 +169,7 @@
                 break;
             }
         }
+
         // Lane count from member tags
         for (RelationMember rM : relation.getMembers()) {
             // Check lanes
@@ -179,7 +180,11 @@
                     List<Long> laneCounts = new ArrayList<>();
                     long maxLaneCount;
                     if (prim.hasTag("lanes")) {
-                        laneCounts.add(Long.parseLong(prim.get("lanes")));
+                        try {
+                            laneCounts.add(Long.parseLong(prim.get("lanes")));
+                        } catch (NumberFormatException e) {
+                            return Collections.emptyMap();
+                        }
                     }
                     for (Entry<String, String> entry : primKeys.entrySet()) {
                         String thisKey = entry.getKey();
Index: test/unit/org/openstreetmap/josm/data/validation/tests/ConnectivityRelationsTest.java
===================================================================
--- test/unit/org/openstreetmap/josm/data/validation/tests/ConnectivityRelationsTest.java	(revision 19413)
+++ test/unit/org/openstreetmap/josm/data/validation/tests/ConnectivityRelationsTest.java	(working copy)
@@ -2,6 +2,7 @@
 package org.openstreetmap.josm.data.validation.tests;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
@@ -8,6 +9,7 @@
 import org.openstreetmap.josm.TestUtils;
 import org.openstreetmap.josm.data.coor.LatLon;
 import org.openstreetmap.josm.data.osm.Node;
+import org.openstreetmap.josm.data.osm.OsmPrimitive;
 import org.openstreetmap.josm.data.osm.Relation;
 import org.openstreetmap.josm.data.osm.RelationMember;
 
@@ -99,4 +101,29 @@
         check.visit(relation);
         assertEquals(++expectedFailures, check.getErrors().size());
     }
+
+    /**
+     * Non-regression test for <a href="https://josm.openstreetmap.de/ticket/201821">Bug #20182</a>.
+     */
+    @Test
+    void testTicket24368() {
+        Relation relation = createDefaultTestRelation();
+        check.visit(relation);
+
+        assertEquals(0, check.getErrors().size());
+
+        // change lanes for one way to an invalid value as reported in the ticket
+        boolean changed = false;
+        for (OsmPrimitive m : relation.getChildren()) {
+            if ("4".equals(m.get("lanes"))) {
+                m.put("lanes", "25 mph");
+                changed = true;
+                break;
+            }
+        }
+        assertTrue(changed);
+        check.visit(relation);
+        assertEquals(0, check.getErrors().size());
+
+    }
 }
