[jira] [Commented] (FOP-3172) image-loading configuration settings are not thread-safe
[ https://issues.apache.org/jira/browse/FOP-3172?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17831715#comment-17831715 ] João André Gonçalves commented on FOP-3172: --- Hi, worth having a look at _FopConfParser.configureImageLoading._ The penalties are saved with a HashMap, so if you try to set different penalties for the same class the penalty value will be replaced with whatever was last. Does this happen if you run the processes one at a time and not in parallel? > image-loading configuration settings are not thread-safe > > > Key: FOP-3172 > URL: https://issues.apache.org/jira/browse/FOP-3172 > Project: FOP > Issue Type: Bug > Components: image/unqualified >Affects Versions: 2.9 >Reporter: Martin Leitner >Priority: Major > > As a workaround for FOP-3171 I added an section to the config > and noticed that the settings will take effect on all subsequent renderings > in the same VM, even when they use a different config or none at all. When > running two or more rendering processes with different configs in parallel, > the result will basically be random. > At the very least, this behaviour should be documented and warned about. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (FOP-3172) image-loading configuration settings are not thread-safe
[ https://issues.apache.org/jira/browse/FOP-3172?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17831717#comment-17831717 ] Martin Leitner commented on FOP-3172: - Hi [~jgoncalves], when I run the processes one at a time, configured penalties will stay in effect until another process uses a config that sets a different value. When running the processes in parallel in different threads at (nearly) the same time, and they use different configs with different penalty values for the same class, it is random which config wins. I guess it is the config that is put in effect last. > image-loading configuration settings are not thread-safe > > > Key: FOP-3172 > URL: https://issues.apache.org/jira/browse/FOP-3172 > Project: FOP > Issue Type: Bug > Components: image/unqualified >Affects Versions: 2.9 >Reporter: Martin Leitner >Priority: Major > > As a workaround for FOP-3171 I added an section to the config > and noticed that the settings will take effect on all subsequent renderings > in the same VM, even when they use a different config or none at all. When > running two or more rendering processes with different configs in parallel, > the result will basically be random. > At the very least, this behaviour should be documented and warned about. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (FOP-3172) image-loading configuration settings are not thread-safe
[ https://issues.apache.org/jira/browse/FOP-3172?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17831718#comment-17831718 ] Simon Steiner commented on FOP-3172: Are you running a different fopfactory per thread, which is required > image-loading configuration settings are not thread-safe > > > Key: FOP-3172 > URL: https://issues.apache.org/jira/browse/FOP-3172 > Project: FOP > Issue Type: Bug > Components: image/unqualified >Affects Versions: 2.9 >Reporter: Martin Leitner >Priority: Major > > As a workaround for FOP-3171 I added an section to the config > and noticed that the settings will take effect on all subsequent renderings > in the same VM, even when they use a different config or none at all. When > running two or more rendering processes with different configs in parallel, > the result will basically be random. > At the very least, this behaviour should be documented and warned about. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (FOP-3172) image-loading configuration settings are not thread-safe
[ https://issues.apache.org/jira/browse/FOP-3172?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17831721#comment-17831721 ] Martin Leitner commented on FOP-3172: - Hi [~ssteiner], yes, every rendering process creates its own FopFactory. > image-loading configuration settings are not thread-safe > > > Key: FOP-3172 > URL: https://issues.apache.org/jira/browse/FOP-3172 > Project: FOP > Issue Type: Bug > Components: image/unqualified >Affects Versions: 2.9 >Reporter: Martin Leitner >Priority: Major > > As a workaround for FOP-3171 I added an section to the config > and noticed that the settings will take effect on all subsequent renderings > in the same VM, even when they use a different config or none at all. When > running two or more rendering processes with different configs in parallel, > the result will basically be random. > At the very least, this behaviour should be documented and warned about. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (FOP-3172) image-loading configuration settings are not thread-safe
[ https://issues.apache.org/jira/browse/FOP-3172?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17831870#comment-17831870 ] Simon Steiner commented on FOP-3172: what if you create a fopfactory and pass in your fop.xconf as the 2nd param: FopFactory newInstance(URI baseURI, InputStream confStream) > image-loading configuration settings are not thread-safe > > > Key: FOP-3172 > URL: https://issues.apache.org/jira/browse/FOP-3172 > Project: FOP > Issue Type: Bug > Components: image/unqualified >Affects Versions: 2.9 >Reporter: Martin Leitner >Priority: Major > > As a workaround for FOP-3171 I added an section to the config > and noticed that the settings will take effect on all subsequent renderings > in the same VM, even when they use a different config or none at all. When > running two or more rendering processes with different configs in parallel, > the result will basically be random. > At the very least, this behaviour should be documented and warned about. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (FOP-3172) image-loading configuration settings are not thread-safe
[ https://issues.apache.org/jira/browse/FOP-3172?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17832119#comment-17832119 ] Martin Leitner commented on FOP-3172: - Attached a Maven project with 2 unit tests that demonstrate the sequential and the parallel use case. > image-loading configuration settings are not thread-safe > > > Key: FOP-3172 > URL: https://issues.apache.org/jira/browse/FOP-3172 > Project: FOP > Issue Type: Bug > Components: image/unqualified >Affects Versions: 2.9 >Reporter: Martin Leitner >Priority: Major > Attachments: fop_3172.zip > > > As a workaround for FOP-3171 I added an section to the config > and noticed that the settings will take effect on all subsequent renderings > in the same VM, even when they use a different config or none at all. When > running two or more rendering processes with different configs in parallel, > the result will basically be random. > At the very least, this behaviour should be documented and warned about. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (FOP-3172) image-loading configuration settings are not thread-safe
[ https://issues.apache.org/jira/browse/FOP-3172?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17832411#comment-17832411 ] Peter Hull commented on FOP-3172: - I had a little dig into this. As I understand it, creating a FopFactory creates a FopFactoryBuilder, which in turn creates a FopFactoryConfigImpl. FopFactoryConfigImpl creates an ImageManager. The ImageManager stores data, including the 'Additional Penalties' which are the issue here, in ImageImplRegistry, which is a singleton class. So ultimately it's this single instance that is responsible for the carry-over of properties from one FopFactory to the next, and it doesn't seem like there is a simple way to avoid that. For reference the classes are, * org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry in xmlgraphics-commons-2.9.jar * org.apache.xmlgraphics.image.loader.ImageManager in in xmlgraphics-commons-2.9.jar * org.apache.fop.apps.FopFactoryBuilder in fop-core-2.9.jar * org.apache.fop.apps.FopConfParser in fop-core-2.9.jar > image-loading configuration settings are not thread-safe > > > Key: FOP-3172 > URL: https://issues.apache.org/jira/browse/FOP-3172 > Project: FOP > Issue Type: Bug > Components: image/unqualified >Affects Versions: 2.9 >Reporter: Martin Leitner >Priority: Major > Attachments: fop_3172.zip > > > As a workaround for FOP-3171 I added an section to the config > and noticed that the settings will take effect on all subsequent renderings > in the same VM, even when they use a different config or none at all. When > running two or more rendering processes with different configs in parallel, > the result will basically be random. > At the very least, this behaviour should be documented and warned about. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (FOP-3172) image-loading configuration settings are not thread-safe
[ https://issues.apache.org/jira/browse/FOP-3172?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17833024#comment-17833024 ] Martin Leitner commented on FOP-3172: - Thanks [~peterhull90] for the analysis! I totally agree that this is what is going on. I do not see why there would be no simple way to avoid that. I suggest to change line 420 in {color:#00}{color:#00}FopFactoryBuilder{color}{color}${color:#00}{color:#00}FopFactoryConfigImpl{color}{color} from {color:#00}{color:#7f0055}this{color}{color:#00}.{color}{color:#c0}imageManager{color}{color:#00} = {color}{color:#7f0055}new{color}{color:#00} ImageManager({color}{color:#7f0055}new{color}{color:#00} ImageContextImpl({color}{color:#7f0055}this{color}{color:#00}));{color}{color} to {color:#00}{color:#7f0055}this{color}{color:#00}.{color}{color:#c0}imageManager{color}{color:#00} = {color}{color:#7f0055}new{color}{color:#00} ImageManager({color:#00}{color:#7f0055}new{color} ImageImplRegistry(){color}, {color}{color:#7f0055}new{color}{color:#00} ImageContextImpl({color}{color:#7f0055}this{color}{color:#00}));{color}{color} > image-loading configuration settings are not thread-safe > > > Key: FOP-3172 > URL: https://issues.apache.org/jira/browse/FOP-3172 > Project: FOP > Issue Type: Bug > Components: image/unqualified >Affects Versions: 2.9 >Reporter: Martin Leitner >Priority: Major > Attachments: fop_3172.zip > > > As a workaround for FOP-3171 I added an section to the config > and noticed that the settings will take effect on all subsequent renderings > in the same VM, even when they use a different config or none at all. When > running two or more rendering processes with different configs in parallel, > the result will basically be random. > At the very least, this behaviour should be documented and warned about. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (FOP-3172) image-loading configuration settings are not thread-safe
[ https://issues.apache.org/jira/browse/FOP-3172?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17833270#comment-17833270 ] Peter Hull commented on FOP-3172: - That looks straightforward but someone who knows the codebase better will have to comment on whether it relies on having one single registry shared across all components (the two-arg constructor you mention says "for testing purposes" in the comments) > image-loading configuration settings are not thread-safe > > > Key: FOP-3172 > URL: https://issues.apache.org/jira/browse/FOP-3172 > Project: FOP > Issue Type: Bug > Components: image/unqualified >Affects Versions: 2.9 >Reporter: Martin Leitner >Priority: Major > Attachments: fop_3172.zip > > > As a workaround for FOP-3171 I added an section to the config > and noticed that the settings will take effect on all subsequent renderings > in the same VM, even when they use a different config or none at all. When > running two or more rendering processes with different configs in parallel, > the result will basically be random. > At the very least, this behaviour should be documented and warned about. -- This message was sent by Atlassian Jira (v8.20.10#820010)