[ 
https://issues.apache.org/jira/browse/FOP-2970?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17615741#comment-17615741
 ] 

Oliver Kaiser commented on FOP-2970:
------------------------------------

I've hit the same problem after updating from 2.3.
FopFactory probably wasn't entirely thread-safe in 2.3, but it did work (after 
calling factory.newFOUserAgent().newFop() once on the main thread).

Some measurements show that for my use case not sharing FopFactory (or sharing 
thread-local) can cause up to 200% performance degradation.

My best workaround is a custom Configuration impl that evaluates a 
DefaultConfiguration once and caches the values in a thread-safe way. So far 
this seems to avoid the bug.

The main problem is that many relevant classes are not really accessible; e.g. 
copy-paste & liberal use of reflection
 - FopFactory is final and obviously not meant to be overloaded
 - FOUserAgent ctor is package private
 - NullConfiguration is package private
 - access to DefaultConfiguration impl details (getValue0(), getElement()) 
required or at least helpful

Is this approach sensible? Would you accept such a patch (in a cleaned up form)?
If not, would you be willing to open up some of those classes to enable a less 
hacky out-of-tree fix?

> Exception when loading the config
> ---------------------------------
>
>                 Key: FOP-2970
>                 URL: https://issues.apache.org/jira/browse/FOP-2970
>             Project: FOP
>          Issue Type: Bug
>            Reporter: zouari
>            Priority: Major
>
> Starting with FOP 2.4 the avalon framework is not used anymore.
> Instead, a Configuration implementation has been added to the FOP: 
> org.apache.fop.configuration.DefaultConfiguration
> this new implementation uses the library "xercesImpl-2.11.0.jar" (not 
> thread-safe ).
> In multithreaded applications, I have the following exception:
> {code:java}
> Caused by: java.lang.NullPointerException
>     at org.apache.xerces.dom.ParentNode.nodeListItem(Unknown Source) 
>     at org.apache.xerces.dom.ParentNode.item(Unknown Source) 
>     at 
> org.apache.fop.configuration.DefaultConfiguration.getChild(DefaultConfiguration.java:113)
>  
>     at 
> org.apache.fop.apps.FOUserAgent.getRendererConfiguration(FOUserAgent.java:696)
>  
>     at 
> org.apache.fop.apps.FOUserAgent.getRendererConfig(FOUserAgent.java:673) 
>     at 
> org.apache.fop.render.PrintRendererConfigurator.getRendererConfig(PrintRendererConfigurator.java:91)
>  
>     at 
> org.apache.fop.render.PrintRendererConfigurator.getCustomFontCollection(PrintRendererConfigurator.java:147)
>  
>     at 
> org.apache.fop.render.PrintRendererConfigurator.setupFontInfo(PrintRendererConfigurator.java:127)
>  
>     at org.apache.fop.render.intermediate.IFUtil.setupFonts(IFUtil.java:170) 
>     at 
> org.apache.fop.render.intermediate.IFRenderer.setupFontInfo(IFRenderer.java:187)
>  
>     at org.apache.fop.area.RenderPagesModel.<init>(RenderPagesModel.java:79) 
>     at 
> org.apache.fop.area.AreaTreeHandler.setupModel(AreaTreeHandler.java:150) 
>     at org.apache.fop.area.AreaTreeHandler.<init>(AreaTreeHandler.java:113) 
>     at org.apache.fop.area.AreaTreeHandler.<init>(AreaTreeHandler.java:132) 
>     at 
> org.apache.fop.layoutmgr.PageSequenceLayoutManager.<init>(PageSequenceLayoutManager.java:136)
>  
>     at 
> org.apache.fop.layoutmgr.LayoutManagerMapping.makePageSequenceLayoutManager(LayoutManagerMapping.java:205)
>  
>     at 
> org.apache.fop.area.AreaTreeHandler.endPageSequence(AreaTreeHandler.java:290) 
>     at 
> org.apache.fop.fo.pagination.PageSequence.endOfNode(PageSequence.java:158) 
>     at 
> org.apache.fop.fo.FOTreeBuilder$MainFOHandler.endElement(FOTreeBuilder.java:362)
>  
>     at org.apache.fop.fo.FOTreeBuilder.endElement(FOTreeBuilder.java:190) 
>     at 
> org.apache.xalan.transformer.TransformerIdentityImpl.endElement(TransformerIdentityImpl.java:1102)
>  
>     at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source) 
>     at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown 
> Source) 
>     at 
> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown
>  Source) 
>     at 
> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown 
> Source) 
>     at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) 
>     at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) 
>     at org.apache.xerces.parsers.XMLParser.parse(Unknown Source) 
>     at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source) 
>     at 
> org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:485)
>  
> {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to