Changeset 19462 in josm for trunk


Ignore:
Timestamp:
2026-01-14T21:41:37+01:00 (43 hours ago)
Author:
stoecker
Message:

should solve Coverity CID 147598 - resource leak

File:
1 edited

Legend:

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

    r19108 r19462  
    5151
    5252    private static final AuxiliaryCacheFactory DISK_CACHE_FACTORY = getDiskCacheFactory();
     53    private static FileChannel cacheDirChannel;
    5354    private static FileLock cacheDirLock;
    5455
     
    118119                        Logging.warn("Cannot create cache dir lock file");
    119120                    }
    120                     cacheDirLock = FileChannel.open(cacheDirLockPath.toPath(), StandardOpenOption.WRITE).tryLock();
     121                    cacheDirChannel = FileChannel.open(cacheDirLockPath.toPath(), StandardOpenOption.WRITE);
     122                    cacheDirLock = cacheDirChannel.tryLock();
    121123
    122124                    if (cacheDirLock == null)
     
    220222     */
    221223    public static void shutdown() {
     224        try {
     225            if (cacheDirLock != null)
     226                cacheDirLock.release();
     227            if (cacheDirChannel != null)
     228                cacheDirChannel.close();
     229        } catch (IOException e) {
     230            Logging.error(e);
     231        }
    222232        JCS.shutdown();
    223233    }
Note: See TracChangeset for help on using the changeset viewer.