FeatureTypeRegistry of gt-complex is not thread-safe
Description
When the WFSContentDataAccess calls getSchema from different threads, we will often get this exception. Looking at the code in createFoundationTypes it is clear that we are holding a lock for the wrong object.
java.util.ConcurrentModificationException at java.base/java.util.HashMap.computeIfAbsent(HashMap.java:1221) at org.geotools.data.complex.feature.type.FeatureTypeRegistry.createFoundationTypes(FeatureTypeRegistry.java:617) at org.geotools.data.complex.feature.type.FeatureTypeRegistry.<init>(FeatureTypeRegistry.java:124) at org.geotools.data.complex.feature.type.FeatureTypeRegistry.<init>(FeatureTypeRegistry.java:106) at org.geotools.data.complex.feature.type.FeatureTypeRegistry.<init>(FeatureTypeRegistry.java:101) at org.geotools.data.wfs.impl.WFSContentDataAccess.getFeatureTypeRegistry(WFSContentDataAccess.java:279) at org.geotools.data.wfs.impl.WFSContentDataAccess.getSchema(WFSContentDataAccess.java:181) at org.geotools.data.wfs.impl.WFSContentComplexFeatureSource.getFeatures(WFSContentComplexFeatureSource.java:97) at org.geotools.data.wfs.impl.WFSContentComplexFeatureSource.getFeatures(WFSContentComplexFeatureSource.java:85)
When the WFSContentDataAccess calls getSchema from different threads, we will often get this exception. Looking at the code in createFoundationTypes it is clear that we are holding a lock for the wrong object.
java.util.ConcurrentModificationException
at java.base/java.util.HashMap.computeIfAbsent(HashMap.java:1221)
at org.geotools.data.complex.feature.type.FeatureTypeRegistry.createFoundationTypes(FeatureTypeRegistry.java:617)
at org.geotools.data.complex.feature.type.FeatureTypeRegistry.<init>(FeatureTypeRegistry.java:124)
at org.geotools.data.complex.feature.type.FeatureTypeRegistry.<init>(FeatureTypeRegistry.java:106)
at org.geotools.data.complex.feature.type.FeatureTypeRegistry.<init>(FeatureTypeRegistry.java:101)
at org.geotools.data.wfs.impl.WFSContentDataAccess.getFeatureTypeRegistry(WFSContentDataAccess.java:279)
at org.geotools.data.wfs.impl.WFSContentDataAccess.getSchema(WFSContentDataAccess.java:181)
at org.geotools.data.wfs.impl.WFSContentComplexFeatureSource.getFeatures(WFSContentComplexFeatureSource.java:97)
at org.geotools.data.wfs.impl.WFSContentComplexFeatureSource.getFeatures(WFSContentComplexFeatureSource.java:85)