Opened 2 years ago

Closed 2 years ago

Last modified 2 years ago

#16193 closed defect (fixed)

IAE: "Parameter 'cache' must not be null" opening a saved session file

Reported by: mpasha Owned by: mpasha
Priority: normal Milestone: 18.04
Component: Core Version: latest
Keywords: template_report cache Cc: wiktorn

Description (last modified by wiktorn)

Repository:UUID: 0c6e7542-c601-0410-84e7-c038aed88b3b
Last:Changed Date: 2018-04-15 23:58:36 +0200 (Sun, 15 Apr 2018)
Build-Date:2018-04-16 01:32:11
Relative:URL: ^/trunk

Identification: JOSM/1.5 (13640 ru) Windows 10 64-Bit
OS Build number: Windows 10 Enterprise 2016 LTSB 1607 (14393)
Memory Usage: 240 MB / 989 MB (75 MB allocated, but free)
Java version: 1.8.0_131-b11, Oracle Corporation, Java HotSpot(TM) Client VM
Screen: \Display0 1366x768
Maximum Screen Size: 1366x768
VM arguments: [-Djosm.home=<josm.pref>]

+ BuildingGeneralization (23)
+ DirectDownload (34109)
+ DirectUpload (34109)
+ FastDraw (34109)
+ HouseNumberTaggingTool (34109)
+ Mapillary (v1.5.10)
+ OpeningHoursEditor (34095)
+ apache-commons (34109)
+ apache-http (34109)
+ buildings_tools (34109)
+ continuosDownload (68)
+ contourmerge (1032)
+ ejml (34126)
+ geotools (34125)
+ gson (34038)
+ imagery_offset_db (34109)
+ jogl (1.1.0)
+ jts (34038)
+ log4j (34038)
+ merge-overlap (34109)
+ namemanager (34109)
+ osm-obj-info (1509723997)
+ photoadjust (34109)
+ reltoolbox (34130)
+ tag2link (34109)
+ tageditor (34109)
+ terracer (34109)
+ utilsplugin2 (34109)

Tagging presets:

Map paint styles:
- D:\Programs\JOSM_Portable\Map Styles\Test\elemstyles standart JOSM.mapcss
- D:\GitHub\New_basic_style_for_JOSM\New_basic_style.mapcss
- D:\GitHub\Ones test style JOSM\Ones test.mapcss
- D:\GitHub\New_basic_style_for_JOSM\New_basic_style - до reformat code.mapcss

Validator rules:
- <josm.pref>\validator\indoorhelper.validator.mapcss

Last errors/warnings:
- W: Already here
- E: Не удалось найти изображение «»
- W:
- W: Already here
- E: Не удалось найти изображение «»
- W:
- E:
- W: Не удается соединиться с сервером OSM. Пожалуйста, проверьте Ваше интернет-соединение.. Причина:
- W: Access denied
- E: Handled by bug report queue: java.lang.IllegalArgumentException: Parameter 'cache' must not be null

No data collected.

Warning issued by: BugReportExceptionHandler#handleException

Thread: AWT-EventQueue-0 (17) of main
java.lang.IllegalArgumentException: Parameter 'cache' must not be null
	at org.openstreetmap.josm.gui.layer.AbstractCachedTileSourceLayer.<init>(
	at org.openstreetmap.josm.gui.layer.TMSLayer.<init>(
	at org.openstreetmap.josm.gui.layer.ImageryLayer.create(
	at org.openstreetmap.josm.actions.SessionLoadAction$Loader.realRun(
	at org.openstreetmap.josm.gui.PleaseWaitRunnable.doRealRun(
	at java.util.concurrent.Executors$
	at java.util.concurrent.ThreadPoolExecutor.runWorker(
	at java.util.concurrent.ThreadPoolExecutor$

Attachments (1)

1111.jos (12.2 KB) - added by anonymous 2 years ago.

Download all attachments as: .zip

Change History (15)

Changed 2 years ago by anonymous

Attachment: 1111.jos added

comment:1 Changed 2 years ago by Don-vip

Cc: wiktorn added
Keywords: cache added

Wiktor can you please take a look to this one? :)

comment:2 Changed 2 years ago by wiktorn


comment:3 Changed 2 years ago by wiktorn

Description: modified (diff)

comment:4 Changed 2 years ago by wiktorn

Owner: changed from team to mpasha
Status: newneedinfo

It looks like JOSM doesn't have access to the cache directory that you set in Imagery Preferences / Settings.

Can you share some details about this folder?

comment:5 Changed 2 years ago by wiktorn

Please, share also session file that generates the problem. Although I revoked myself rights to cache folder I can't reproduce the problem

comment:6 Changed 2 years ago by wiktorn


In following code:

        if (cachePath != null && cacheDirLock != null ) {
            IDiskCacheAttributes diskAttributes = getDiskCacheAttributes(maxDiskObjects, cachePath, cacheName);
            try {
                if (cc.getAuxCaches().length == 0) {
                    cc.setAuxCaches(new AuxiliaryCache[]{DISK_CACHE_FACTORY.createCache(
                            diskAttributes, cacheManager, null, new StandardSerializer())});
            } catch (IOException e) {
                throw e;
            } catch (Exception e) { // NOPMD
                throw new IOException(e);
        return new CacheAccess<>(cc);

Instead of thrown IOException we could just log it and return new CacheAccess<>(cc) or return new CacheAccess<>(cacheManager.getCache(cacheName, getCacheAttributes(maxMemoryObjects))).

This has the drawback is that it will silently (apart from log message) fall back to memory only cache.

What do you think?

PS. Run out of ideas how to reproduce it though

comment:7 Changed 2 years ago by Don-vip

I'm not sure to understand the chain of errors. What kind of exception did we catch in the first place?

comment:8 Changed 2 years ago by wiktorn

My wild guess is, that we got IOException: Access Denied in getCache(). Then we tried to use null cache to instantiate TMSLayer.

comment:9 Changed 2 years ago by Don-vip

OK I think you're right for the Exception in getCache(). But I don't think it comes from the piece of code you pasted, I don't see anywhere IOException being raised, even if we catch it. This sounds more suspect to me:

    private static void initialize() throws IOException {
        /* ... */
        if (!cacheDirLockPath.exists() && !cacheDirLockPath.createNewFile()) {
            Logging.warn("Cannot create cache dir lock file");
        cacheDirLock =, StandardOpenOption.WRITE).tryLock();

The calls createNewFile(), open(), and tryLock() can throw IOException and we don't catch them.

comment:10 Changed 2 years ago by Don-vip

As we already have a fallback:

        if (cacheDirLock == null)
            Logging.warn("Cannot lock cache directory. Will not use disk cache");

I suggest to add a try/catch above and simply log any IOException that could occur. What do you think?

comment:11 Changed 2 years ago by wiktorn

Resolution: fixed
Status: needinfoclosed

In 13643/josm:

In case of any IOExceptions when creating disk cache return memory-only cache

Closes: #16193

comment:12 in reply to:  11 Changed 2 years ago by Don-vip

Milestone: 18.04

Thanks! Can you please keep the // NOPMD? It's needed if we want to keep Exception in the catch clause.

comment:13 Changed 2 years ago by wiktorn

In 13644/josm:

Supress PMD warnings

See: #16193

comment:14 Changed 2 years ago by Don-vip

Summary: Error opening a saved session fileIAE: "Parameter 'cache' must not be null" opening a saved session file

Modify Ticket

Change Properties
Set your email in Preferences
as closed The owner will remain mpasha.
as The resolution will be set.
The resolution will be deleted.

Add Comment

E-mail address and name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.