fgdrf removed a comment on pull request #38:
URL: https://github.com/apache/commons-dbcp/pull/38#issuecomment-833000739
I'd like to add the thread-dump from udig-platform product here:
```
"LayerFactory" #102 daemon prio=5 os_prio=0 tid=0x000000001b681800
nid=0x3158 in Object.wait() [0x0000000028ead000]
java.lang.Thread.State: RUNNABLE
at
org.geotools.filter.function.CategorizeFunction.<init>(CategorizeFunction.java:126)
at
org.geotools.filter.function.CategorizeFunction.<init>(CategorizeFunction.java:99)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at java.lang.Class.newInstance(Class.java:442)
at
java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:380)
at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:404)
at java.util.ServiceLoader$1.next(ServiceLoader.java:480)
at
org.geotools.util.factory.FactoryRegistry.register(FactoryRegistry.java:962)
at
org.geotools.util.factory.FactoryRegistry.scanForPlugins(FactoryRegistry.java:858)
at
org.geotools.util.factory.FactoryRegistry.scanForPluginsIfNeeded(FactoryRegistry.java:888)
at
org.geotools.util.factory.FactoryRegistry.getFactories(FactoryRegistry.java:251)
- locked <0x00000000fd56c710> (a
org.geotools.util.factory.FactoryCreator)
at
org.geotools.factory.CommonFactoryFinder.getFunctions(CommonFactoryFinder.java:134)
- locked <0x00000000fd56c7a0> (a java.lang.Class for
org.geotools.factory.CommonFactoryFinder)
at
org.geotools.filter.function.DefaultFunctionFactory.loadFunctions(DefaultFunctionFactory.java:143)
at
org.geotools.filter.function.DefaultFunctionFactory.functionCache(DefaultFunctionFactory.java:102)
- locked <0x00000000fd56c828> (a
org.geotools.filter.function.DefaultFunctionFactory)
at
org.geotools.filter.function.DefaultFunctionFactory.getFunctionNames(DefaultFunctionFactory.java:60)
at
org.geotools.filter.FunctionFinder.lookupFunctions(FunctionFinder.java:249)
at
org.geotools.filter.FunctionFinder.findFunctionInternal(FunctionFinder.java:222)
- locked <0x00000000fcd21aa0> (a org.geotools.filter.FunctionFinder)
at
org.geotools.filter.FunctionFinder.findFunction(FunctionFinder.java:196)
at
org.geotools.filter.FunctionFinder.findFunction(FunctionFinder.java:153)
at
org.geotools.filter.FunctionFinder.findFunction(FunctionFinder.java:129)
at
org.geotools.filter.FilterFactoryImpl.function(FilterFactoryImpl.java:818)
at
org.geotools.feature.AttributeTypeBuilder.lengthRestriction(AttributeTypeBuilder.java:571)
at
org.geotools.feature.AttributeTypeBuilder.buildType(AttributeTypeBuilder.java:394)
at
org.geotools.feature.AttributeTypeBuilder.buildDescriptor(AttributeTypeBuilder.java:464)
at
org.geotools.data.shapefile.ShapefileFeatureSource.readAttributes(ShapefileFeatureSource.java:573)
at
org.geotools.data.shapefile.ShapefileFeatureSource.buildFeatureType(ShapefileFeatureSource.java:481)
at
org.geotools.data.shapefile.ShapefileFeatureStore.buildFeatureType(ShapefileFeatureStore.java:137)
at
org.geotools.data.store.ContentFeatureSource.getAbsoluteSchema(ContentFeatureSource.java:327)
- locked <0x00000000fce89e60> (a org.geotools.data.store.ContentState)
at
org.geotools.data.store.ContentFeatureSource.getSchema(ContentFeatureSource.java:296)
at
org.geotools.data.store.ContentFeatureSource.getSchema(ContentFeatureSource.java:105)
at
org.locationtech.udig.catalog.internal.shp.ShpGeoResourceImpl.style(ShpGeoResourceImpl.java:172)
at
org.locationtech.udig.catalog.internal.shp.ShpGeoResourceImpl.resolve(ShpGeoResourceImpl.java:153)
at
org.locationtech.udig.project.internal.impl.LayerResource.processResourceCachingStrategy(LayerResource.java:308)
at
org.locationtech.udig.project.internal.impl.LayerResource.resolve(LayerResource.java:173)
- locked <0x00000000fcee9310> (a
org.locationtech.udig.project.internal.impl.LayerResource)
at
org.locationtech.udig.style.sld.SLDContent.createDefaultStyle(SLDContent.java:220)
at
org.locationtech.udig.project.internal.SetDefaultStyleProcessor.process(SetDefaultStyleProcessor.java:45)
at
org.locationtech.udig.core.internal.ExtensionPointUtil.process(ExtensionPointUtil.java:77)
at
org.locationtech.udig.project.internal.SetDefaultStyleProcessor.run(SetDefaultStyleProcessor.java:53)
at
org.locationtech.udig.project.internal.impl.SetStyleInterceptor.run(SetStyleInterceptor.java:33)
at
org.locationtech.udig.project.internal.impl.LayerFactoryImpl.runLayerCreatedInterceptor(LayerFactoryImpl.java:430)
at
org.locationtech.udig.project.internal.impl.LayerFactoryImpl.createLayer(LayerFactoryImpl.java:409)
"Worker-3: Rendering" #67 daemon prio=5 os_prio=0 tid=0x00000000165a5000
nid=0xf14 waiting for monitor entry [0x000000002138e000]
java.lang.Thread.State: BLOCKED (on object monitor)
at
org.geotools.factory.CommonFactoryFinder.lookup(CommonFactoryFinder.java:258)
- waiting to lock <0x00000000fd56c7a0> (a java.lang.Class for
org.geotools.factory.CommonFactoryFinder)
at
org.geotools.factory.CommonFactoryFinder.getFilterFactory(CommonFactoryFinder.java:213)
at
org.geotools.factory.CommonFactoryFinder.getFilterFactory2(CommonFactoryFinder.java:299)
at
org.geotools.factory.CommonFactoryFinder.getFilterFactory2(CommonFactoryFinder.java:312)
at
org.geotools.filter.FilterAttributeExtractor.<clinit>(FilterAttributeExtractor.java:51)
at
org.locationtech.udig.render.internal.feature.basic.BasicFeatureRenderer.getExpandSizeFromStyle(BasicFeatureRenderer.java:271)
at
org.locationtech.udig.render.internal.feature.basic.BasicFeatureRenderer.getStyle(BasicFeatureRenderer.java:241)
at
org.locationtech.udig.render.internal.feature.basic.BasicFeatureRenderer.prepareDraw(BasicFeatureRenderer.java:160)
at
org.locationtech.udig.render.internal.feature.basic.BasicFeatureRenderer.render(BasicFeatureRenderer.java:349)
at
org.locationtech.udig.render.internal.feature.basic.BasicFeatureRenderer.render(BasicFeatureRenderer.java:312)
at
org.locationtech.udig.project.internal.render.impl.RenderJob.startRendering(RenderJob.java:134)
at
org.locationtech.udig.project.internal.render.impl.RenderJob.run(RenderJob.java:258)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
````
Scenario: two bundles are loading content in different threads the first one
added a layer which caused the renderer to start, the second one tries to read
SLD from a file. See lock 0x00000000fd56c7a0
IMHO, I cannot provide a Test-Case for this scenario. My understanding is
that it should be avoided to initialize static fields with method calles that
execute synchronized code.
An approach could be having a internal static class that holds the field.
This class is not loaded from any classloader unless invoked in e.g.
visit-method of FilterAttributeExtractor:
```
private static final class FilterFactory2Holder {
static final FilterFactory2 FF =
CommonFactoryFinder.getFilterFactory2();
}
[..]
if (name != null) {
attributeNames.add(name);
propertyNames.add(FilterFactory2Holder.FF.property(name));
foundLiteral = true;
}
[..]
```
This is thread-safe rathe than having a private static method to initialize
FilterFactory2 lazily.
I've analyzed the geotools (22.1 tag which is currently used in uDig) where
other final static initializations are used accessing CommonFactoryFinder, here
is the list:
- org.geotools.arcsde.filter.ArcSdeSimplifyingFilterVisitor
- org.geotools.brewer.color.StyleGenerator
- org.geotools.brewer.styling.builder.AbstractSLDBuilder
- org.geotools.data.DataUtilities
- org.geotools.data.Join
- org.geotools.data.complex.filter.UnmappingFilterVisitor
- org.geotools.data.jdbc.FilterToSQL
- org.geotools.data.store.ReprojectingFeatureCollection
- org.geotools.data.transform.Definition
- org.geotools.data.transform.TransformFeatureSource
- org.geotools.data.transform.Transformer
- org.geotools.feature.visitor.SumAreaVisitor
- org.geotools.filter.FilterAttributeExtractor
- org.geotools.filter.FilterDOMParser
- org.geotools.filter.FunctionImpl
- org.geotools.filter.function.EqualAreaFunction
- org.geotools.filter.function.InterpolateFunction
- org.geotools.filter.function.RecodeFunction
- org.geotools.gce.imagemosaic.Utils
- org.geotools.gce.imagemosaic.catalog.GranuleCatalogStore
- org.geotools.process.vector.ClassifyByRangeProcess
- org.geotools.process.vector.FeatureClassStats
- org.geotools.renderer.lite.CompositingGroup
- org.geotools.renderer.lite.GraphicsAwareDpiRescaleStyleVisitor
- org.geotools.renderer.lite.RenderingTransformationHelper
- org.geotools.renderer.lite.StreamingRenderer
- org.geotools.renderer.lite.ZGroupLayerFactory
- org.geotools.renderer.style.ExpressionExtractor
- org.geotools.renderer.style.SLDStyleFactory
- org.geotools.styling.SLD
- org.geotools.styling.visitor.Measure
- org.geotools.swing.styling.JFontChooser
- org.geotools.swing.styling.JFontChooser
- org.geotools.swing.styling.JSimpleStyleDialog
- org.geotools.swing.tool.FeatureLayerHelper
- org.geotools.validation.xml.ArgHelper
- org.geotools.wfs.PropertyValueCollection
- org.geotools.xml.styling.SLDParser
- org.geotools.xml.styling.SLDTransformer
- org.geotools.xml.styling.SLDTransformer
Finally:
- Could anyone join and help providing a testcase for this. IMO it requires
to have its own Classloader(s) to make sure CommonFactoryFinder haven't
initialized already (in another test-case).
- would you accept Holder-Class aproach w/o any testcase?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]