Opened 9 years ago

Closed 9 years ago

Last modified 7 years ago

#11466 closed defect (fixed)

ConcurrentModificationException in java.util.HashMap

Reported by: anonymous Owned by: team
Priority: normal Milestone: 15.05
Component: Core Version:
Keywords: Cc:



I have recently reported other tickets, and this is what I was doing: #11463 and #11461

This time I just launched JOSM (no internet connection, was just pre-loading it), and did not work.


Repository Root:
Build-Date: 2015-05-08 01:31:23
Last Changed Author: stoecker
Revision: 8339
Repository UUID: 0c6e7542-c601-0410-84e7-c038aed88b3b
Relative URL: ^/trunk
Last Changed Date: 2015-05-07 17:30:43 +0200 (Thu, 07 May 2015)
Last Changed Rev: 8339

Identification: JOSM/1.5 (8339 en) Linux Ubuntu 14.04.2 LTS
Memory Usage: 326 MB / 857 MB (262 MB allocated, but free)
Java version: 1.7.0_79, Oracle Corporation, OpenJDK 64-Bit Server VM
Java package: openjdk-7-jre:amd64-7u79-2.5.5-0ubuntu0.14.04.2
VM arguments: [-Djosm.restart=true,]

- DirectUpload (30892)
- ImportImagePlugin (31114)
- PicLayer (31114)
- editgpx (30892)
- geotools (31068)
- jts (31002)
- log4j (30892)
- opendata (31116)
- utilsplugin2 (31120)

Last errors/warnings:
- E: Broken tagging preset "surface-Surface" - number of items in 'display_values' must be the same as in 'values'
- E: Broken tagging preset "surface-Surface" - number of items in 'display_values' must be the same as in 'values'
- E: java.util.ConcurrentModificationException
- E: Connection to proxy 'wpad.icrc.visitor:8080' for URI '' failed. Exception was: wpad.icrc.visitor
- W: Unable to detect latest version of JOSM: Unknown proxy type : HTTP

	at java.util.HashMap$HashIterator.nextEntry(
	at java.util.HashMap$
	at java.util.HashMap$
	at org.openstreetmap.josm.gui.preferences.ToolbarPreferences.loadActions(
	at org.openstreetmap.josm.gui.preferences.ToolbarPreferences.getDefinedActions(
	at org.openstreetmap.josm.gui.preferences.ToolbarPreferences.refreshToolbarControl(
	at org.openstreetmap.josm.gui.MainApplication.main(

Attachments (0)

Change History (9)

comment:1 by wiktorn, 9 years ago


this should be easily fixed (I guess) using ConcurrentHashMap, just as Sonar issue suggests:

Shall we (more less) blindly replace all HashMaps with ConcurrentHashMaps?

Based on:

I would go with the recommendation from the latter and do:
new ConcurrentHashMap<>(8, 0.9f, 1); instead of new HashMap<>() as the performance of ConcurrentHashMap is not significantly worse than unsafe HashMap.

Unless we have some better clues about the usage of the map.

Last edited 9 years ago by wiktorn (previous) (diff)

comment:2 by wiktorn, 9 years ago

The second one looks like it was based on Java 6, so this might be not an issue right now.

comment:4 by wiktorn, 9 years ago

There is an comment on the second blog post:

Just noting that ConcurrentHashMap was revised in Java 7 to use lazy segment initialization, so the memory waste that used to occur with the default constructor is now mitigated. An empty map now contains a single segment.
However, the lazy initialization is triggered by puts to missing segments and NOT by contention. ConcurrentHashMapV8 which may replace ConcurrentHashMap in Java 8, does not use a fixed lock striping scheme at all, instead each bucket serves as a “stripe” using intrinsic synchronization.

comment:5 by Don-vip, 9 years ago

Milestone: 15.05
Summary: Crashes on launchConcurrentModificationException in java.util.HashMap

OK then the default new ConcurrentHashMap<>() sounds good.

comment:6 by wiktorn, 9 years ago

Resolution: fixed
Status: newclosed

In 8422/josm:

Change HashMap to ConcurrentHashMap, to avoid ConcurrentModificationException. Closes #11466

comment:7 by Don-vip, 9 years ago

Resolution: fixed
Status: closedreopened

There are two problems in the Jenkins build:

it seems linked to the handling of empty/null values, it seems it was ok to have empty values before.

comment:8 by wiktorn, 9 years ago

Resolution: fixed
Status: reopenedclosed

In 8423/josm:

Fix unit tests and findbugs warning. Closes: #11466

comment:9 by anonymous, 9 years ago

Referenced in build JOSM 8423

Modify Ticket

Change Properties
Set your email in Preferences
as closed The owner will remain team.
as The resolution will be set.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment

E-mail address and name can be saved in the Preferences .
Note: See TracTickets for help on using tickets.