WMS GetCapabilities throws ConcurrentModificationException

Description

WMS GetCapabilities requests will throw a ConcurrentModificationException.

In my environment, this is 100% reproducible by making the GetCapabilities request without any configuration modifications happening.
Based upon my understanding, I believe the error happens whenever the inner if block removes an element from the map.
The bug should only impact some custom dimensions.
https://stackoverflow.com/questions/49688057/can-i-use-keyset-to-modify-hashmap-during-iteration

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 DimensionHelper (block around line 233) // Process only custom dimensions supported by the reader if (hasCustomDimensions) { for (String key : customDimensions.keySet()) { if (!dimensions.hasDomain(key)) customDimensions.remove(key); } } 2018-10-10 10:09:38,232 WARN [wms.capabilities] - Error writing metadata; skipping layer: EchoBottomsMosaicFlagsForPrecipLevel java.util.ConcurrentModificationException at java.util.HashMap$HashIterator.nextNode(HashMap.java:1437) at java.util.HashMap$KeyIterator.next(HashMap.java:1461) at org.geoserver.wms.capabilities.DimensionHelper.handleRasterLayerDimensions(DimensionHelper.java:233) at org.geoserver.wms.capabilities.Capabilities_1_3_0_Transformer$Capabilities_1_3_0_Translator.handleLayer(Capabilities_1_3_0_Transformer.java:1015) at org.geoserver.wms.capabilities.Capabilities_1_3_0_Transformer$Capabilities_1_3_0_Translator.doHandleLayer(Capabilities_1_3_0_Transformer.java:936) at org.geoserver.wms.capabilities.Capabilities_1_3_0_Transformer$Capabilities_1_3_0_Translator.handleLayerTree(Capabilities_1_3_0_Transformer.java:896) at org.geoserver.wms.capabilities.Capabilities_1_3_0_Transformer$Capabilities_1_3_0_Translator.handleLayers(Capabilities_1_3_0_Transformer.java:734) at org.geoserver.wms.capabilities.Capabilities_1_3_0_Transformer$Capabilities_1_3_0_Translator.handleCapability(Capabilities_1_3_0_Transformer.java:478) at org.geoserver.wms.capabilities.Capabilities_1_3_0_Transformer$Capabilities_1_3_0_Translator.encode(Capabilities_1_3_0_Transformer.java:288) at org.geotools.xml.transform.TransformerBase$XMLReaderSupport.parse(TransformerBase.java:996) at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transformIdentity(TransformerImpl.java:668) at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:737) at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:351) at org.geotools.xml.transform.TransformerBase$Task.run(TransformerBase.java:284) at org.geotools.xml.transform.TransformerBase.transform(TransformerBase.java:119) at org.geotools.xml.transform.TransformerBase.transform(TransformerBase.java:101) at org.geoserver.wms.capabilities.Capabilities_1_3_0_Response.write(Capabilities_1_3_0_Response.java:43) at org.geoserver.config.CapabilitiesCacheHeadersCallback$RevalidateTagResponse.write(CapabilitiesCacheHeadersCallback.java:144)

Environment

None

Status

Assignee

Andrea Aime

Reporter

Jerry Wilwerding

Triage

Fix versions

Affects versions

2.14.0

Priority

Medium
Configure