Changeset 36082 in osm


Ignore:
Timestamp:
2023-05-16T16:16:14+02:00 (19 months ago)
Author:
taylor.smock
Message:

Fix #22946: NullPointerException in DrawnPolyLine#autoSimplify

Location:
applications/editors/josm/plugins/FastDraw
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/FastDraw/src/org/openstreetmap/josm/plugins/fastdraw/DrawnPolyLine.java

    r36056 r36082  
    157157            e = e * ekf;
    158158            simplify(e);
    159             Logging.trace("DrawnPolyLine: eps={0} n={1}", e, simplePoints.size());
     159            if (simplePoints != null) {
     160                Logging.trace("DrawnPolyLine: eps={0} n={1}", e, simplePoints.size());
     161            }
    160162        }
    161163        return e;
  • applications/editors/josm/plugins/FastDraw/test/unit/org/openstreetmap/josm/plugins/fastdraw/DrawnPolyLineTest.java

    r36059 r36082  
    7272        assertDoesNotThrow(() -> this.drawnPolyLine.getLastPoint());
    7373    }
     74
     75    /**
     76     * Non-regression test for #22946: NullPointerException in {@link DrawnPolyLine#autoSimplify(double, double, int, double)}
     77     * The root issue is probably from some kind of race condition.
     78     */
     79    @Test
     80    void testNonRegression22946() {
     81        this.drawnPolyLine.addLast(new LatLon(0.00001, 0.00001));
     82        this.drawnPolyLine.addLast(new LatLon(0.00002, 0.00002));
     83        this.drawnPolyLine.addLast(new LatLon(0.00002, 0.00003));
     84        this.drawnPolyLine.clear();
     85        // The maxPKM == -.1 to force the bad code path. As noted, it is probably a race condition issue.
     86        assertDoesNotThrow(() -> this.drawnPolyLine.autoSimplify(5, 1.1, 10, -.1));
     87    }
    7488}
Note: See TracChangeset for help on using the changeset viewer.