Modify

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:

Description

Hi,

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.

Cheers,

Repository Root: http://josm.openstreetmap.de/svn
Build-Date: 2015-05-08 01:31:23
Last Changed Author: stoecker
Revision: 8339
Repository UUID: 0c6e7542-c601-0410-84e7-c038aed88b3b
Relative URL: ^/trunk
URL: http://josm.openstreetmap.de/svn/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, -Djava.net.useSystemProxies=true]

Plugins:
- 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 'https://josm.openstreetmap.de/wiki/TestedVersion?format=txt' failed. Exception was: java.net.UnknownHostException: wpad.icrc.visitor
- W: Unable to detect latest version of JOSM: Unknown proxy type : HTTP

java.util.ConcurrentModificationException
	at java.util.HashMap$HashIterator.nextEntry(HashMap.java:922)
	at java.util.HashMap$EntryIterator.next(HashMap.java:962)
	at java.util.HashMap$EntryIterator.next(HashMap.java:960)
	at org.openstreetmap.josm.gui.preferences.ToolbarPreferences.loadActions(ToolbarPreferences.java:952)
	at org.openstreetmap.josm.gui.preferences.ToolbarPreferences.getDefinedActions(ToolbarPreferences.java:980)
	at org.openstreetmap.josm.gui.preferences.ToolbarPreferences.refreshToolbarControl(ToolbarPreferences.java:1034)
	at org.openstreetmap.josm.gui.MainApplication.main(MainApplication.java:454)

Attachments (0)

Change History (9)

comment:1 by wiktorn, 9 years ago

@team:

this should be easily fixed (I guess) using ConcurrentHashMap, just as Sonar issue suggests:
http://josm.openstreetmap.de/sonar/issues/search#issues=eb53df2c-c107-469e-8936-9a95f7ad67b0

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

Based on:
http://java.dzone.com/articles/java-7-hashmap-vs
https://ria101.wordpress.com/2011/12/12/concurrenthashmap-avoid-a-common-misuse/

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
Action
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.