Ticket #18601: 18601.core_synchronized.patch

File 18601.core_synchronized.patch, 1012 bytes (added by taylor.smock, 6 years ago)

Synchronzie if block to ensure that the AbstractPrimitive current unique id is not incremented backwards accidentally

  • src/org/openstreetmap/josm/io/AbstractReader.java

     
    326326            throw new IllegalDataException(e);
    327327        } finally {
    328328            OptionalLong minId = externalIdMap.values().stream().mapToLong(AbstractPrimitive::getUniqueId).min();
    329             if (minId.isPresent() && minId.getAsLong() < AbstractPrimitive.currentUniqueId()) {
    330                 AbstractPrimitive.advanceUniqueId(minId.getAsLong());
     329            synchronized (AbstractPrimitive.class) {
     330                if (minId.isPresent() && minId.getAsLong() < AbstractPrimitive.currentUniqueId()) {
     331                    AbstractPrimitive.advanceUniqueId(minId.getAsLong());
     332                }
    331333            }
    332334            progressMonitor.finishTask();
    333335            progressMonitor.removeCancelListener(cancelListener);