Changeset 15525 in josm for trunk


Ignore:
Timestamp:
2019-11-17T18:37:18+01:00 (4 years ago)
Author:
Don-vip
Message:

spotbugs - JLM_JSR166_UTILCONCURRENT_MONITORENTER

Location:
trunk/src/org/openstreetmap/josm/data
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/cache/HostLimitQueue.java

    r14261 r15525  
    130130        Semaphore limit = hostSemaphores.get(host);
    131131        if (limit == null) {
    132             synchronized (hostSemaphores) {
    133                 limit = hostSemaphores.computeIfAbsent(host, k -> new Semaphore(hostLimit));
    134             }
     132            limit = hostSemaphores.computeIfAbsent(host, k -> new Semaphore(hostLimit));
    135133        }
    136134        return limit;
  • trunk/src/org/openstreetmap/josm/data/cache/JCSCachedTileLoaderJob.java

    r14535 r15525  
    153153            throw new IllegalArgumentException("No url returned");
    154154        }
    155         synchronized (inProgress) {
    156             Set<ICachedLoaderListener> newListeners = inProgress.get(deduplicationKey);
    157             if (newListeners == null) {
    158                 newListeners = new HashSet<>();
    159                 inProgress.put(deduplicationKey, newListeners);
    160                 first = true;
    161             }
    162             newListeners.add(listener);
    163         }
     155        synchronized (this) {
     156            first = !inProgress.containsKey(deduplicationKey);
     157        }
     158        inProgress.computeIfAbsent(deduplicationKey, k -> new HashSet<>()).add(listener);
    164159
    165160        if (first || force) {
     
    250245    private void finishLoading(LoadResult result) {
    251246        Set<ICachedLoaderListener> listeners;
    252         synchronized (inProgress) {
    253             try {
    254                 listeners = inProgress.remove(getUrl().toString());
    255             } catch (IOException e) {
    256                 listeners = null;
    257                 Logging.trace(e);
    258             }
     247        try {
     248            listeners = inProgress.remove(getUrl().toString());
     249        } catch (IOException e) {
     250            listeners = null;
     251            Logging.trace(e);
    259252        }
    260253        if (listeners == null) {
  • trunk/src/org/openstreetmap/josm/data/imagery/TMSCachedTileLoaderJob.java

    r14573 r15525  
    7676        this.options = options;
    7777        if (listener != null) {
    78             String deduplicationKey = getCacheKey();
    79             synchronized (inProgress) {
    80                 inProgress.computeIfAbsent(deduplicationKey, k -> new HashSet<>()).add(listener);
    81             }
     78            inProgress.computeIfAbsent(getCacheKey(), k -> new HashSet<>()).add(listener);
    8279        }
    8380    }
     
    162159    public void loadingFinished(CacheEntry object, CacheEntryAttributes attributes, LoadResult result) {
    163160        this.attributes = attributes; // as we might get notification from other object than our selfs, pass attributes along
    164         Set<TileLoaderListener> listeners;
    165         synchronized (inProgress) {
    166             listeners = inProgress.remove(getCacheKey());
    167         }
     161        Set<TileLoaderListener> listeners = inProgress.remove(getCacheKey());
    168162        boolean status = result == LoadResult.SUCCESS;
    169163
Note: See TracChangeset for help on using the changeset viewer.