Changeset 18486 in josm for trunk/src/org/openstreetmap


Ignore:
Timestamp:
2022-06-13T15:42:34+02:00 (2 years ago)
Author:
taylor.smock
Message:

Fix CID 1489883: Dereference null return value

This was introduced in r18475, but it was unlikely to ever be a problem,
as the constructor used sets the default element attributes to a non-null
value.

File:
1 edited

Legend:

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

    r18475 r18486  
    22package org.openstreetmap.josm.tools;
    33
     4import java.util.Optional;
    45import java.util.concurrent.TimeUnit;
    56import java.util.regex.Pattern;
    67
    78import org.apache.commons.jcs3.access.CacheAccess;
     9import org.apache.commons.jcs3.engine.ElementAttributes;
    810import org.apache.commons.jcs3.engine.behavior.IElementAttributes;
    911import org.openstreetmap.josm.data.cache.JCSCacheManager;
     
    2426    static {
    2527        // We don't want to keep these around forever, so set a reasonablish max idle life.
    26         final IElementAttributes defaultAttributes = cache.getDefaultElementAttributes();
     28        final IElementAttributes defaultAttributes = Optional.ofNullable(cache.getDefaultElementAttributes()).orElseGet(
     29                ElementAttributes::new);
    2730        defaultAttributes.setIdleTime(TimeUnit.HOURS.toSeconds(1));
    2831        cache.setDefaultElementAttributes(defaultAttributes);
Note: See TracChangeset for help on using the changeset viewer.