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

Environment

None

Activity

Show:
Andrea Aime
November 18, 2018, 8:21 AM

Hi, I agree the code is problematic. In order to commit a fix, we need to write a test (almost no fixes are accepted without one, this might be an exception, to be evaluated).
In order to write a test, one needs to replicate the problem and prepare a small dataset to use in order to trigger the issue.

Looking at the code, I have the impression that in order to have this trigger, one would need a raster dataset that was configured with a custom dimension, which then later it does not have anymore, putting the config out of synch with the reader. Is that right?

Jerry Wilwerding
November 18, 2018, 7:21 PM

Andrea, I believe you are correct. In my environment, I determined two days ago that an improper configuration existed. A custom dimension of forecast_period was being applied to a data set that had no such dimension. I think this is why I was always getting to the problematic section of code and I think this aligns with your theory as well.

The good news is that the cause of my error was corrected by creating a proper configuration. I no longer see the ConcurrentModification exception when I have correct configurations in place. The bad news is that the code can still throw the exception due to improper configuration or, as your theory suggests, data sets changing over time.

The only negative impact I saw was the coverage not being included in the GetCapabilities response. I don't recall if GetCovearge or GetMap was impacted. Since the cause appears to be bad configurations or data sets changing over time, perhaps a WARN message is appropriate to help diagnose the issue?

I think the code could be modified to keep track of dimensions to remove from the keySet as part of the loop processing and then remove the dimensions immediately after the loop.

Assignee

Andrea Aime

Reporter

Jerry Wilwerding

Triage

Fix versions

Affects versions

Priority

Medium
Configure