Changeset 18550 in josm for trunk


Ignore:
Timestamp:
2022-09-07T19:55:04+02:00 (20 months ago)
Author:
taylor.smock
Message:

Fix CID 1497740: Concurrent data access violations

SUPPRESSED_EXCEPTIONS.add was originally not guarded, since
the possible exception could be caused by pop, and I wanted
to prevent that by keeping multiple threads from calling
pop at the same time.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/tools/bugreport/BugReport.java

    r18549 r18550  
    7474     */
    7575    public static void addSuppressedException(Throwable t) {
    76         SUPPRESSED_EXCEPTIONS.add(new Pair<>(Instant.now(), t != null ? t : new NullPointerException()));
    7776        // Ensure we don't call pop in more than MAXIMUM_SUPPRESSED_EXCEPTIONS threads. This guard is
    7877        // here just in case someone doesn't read the javadocs.
    7978        synchronized (SUPPRESSED_EXCEPTIONS) {
     79            SUPPRESSED_EXCEPTIONS.add(new Pair<>(Instant.now(), t != null ? t : new NullPointerException()));
    8080            // Ensure we aren't keeping exceptions forever
    8181            while (SUPPRESSED_EXCEPTIONS.size() > MAXIMUM_SUPPRESSED_EXCEPTIONS) {
Note: See TracChangeset for help on using the changeset viewer.