aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMehdi Houshmand <mehdi@apache.org>2012-04-27 13:11:06 +0000
committerMehdi Houshmand <mehdi@apache.org>2012-04-27 13:11:06 +0000
commitbe77bea9baa51ef4bb6116d85edcf6a5b8f3fd67 (patch)
treea202bbbaaf76b6dd99d8692d64a4c0ded57e9c74 /src
parentc40d6029737141c4d86f3b6bde38ce444f8b3bb7 (diff)
downloadxmlgraphics-fop-be77bea9baa51ef4bb6116d85edcf6a5b8f3fd67.tar.gz
xmlgraphics-fop-be77bea9baa51ef4bb6116d85edcf6a5b8f3fd67.zip
Fixed concurrency issue re:background-image on a fo:block. Also updated a couple license headers in the examples
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1331419 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r--src/java/org/apache/fop/fo/properties/CommonBorderPaddingBackground.java56
1 files changed, 27 insertions, 29 deletions
diff --git a/src/java/org/apache/fop/fo/properties/CommonBorderPaddingBackground.java b/src/java/org/apache/fop/fo/properties/CommonBorderPaddingBackground.java
index 789b8d4ed..0e7f3d978 100644
--- a/src/java/org/apache/fop/fo/properties/CommonBorderPaddingBackground.java
+++ b/src/java/org/apache/fop/fo/properties/CommonBorderPaddingBackground.java
@@ -348,9 +348,7 @@ public class CommonBorderPaddingBackground {
*/
public static CommonBorderPaddingBackground getInstance(PropertyList pList)
throws PropertyException {
-
- CommonBorderPaddingBackground newInstance
- = new CommonBorderPaddingBackground(pList);
+ CommonBorderPaddingBackground newInstance = new CommonBorderPaddingBackground(pList);
CommonBorderPaddingBackground cachedInstance = null;
/* if padding-* and background-position-* resolve to absolute lengths
* the whole instance can be cached */
@@ -368,33 +366,33 @@ public class CommonBorderPaddingBackground {
|| newInstance.backgroundPositionVertical.isAbsolute())) {
cachedInstance = CACHE.fetch(newInstance);
}
-
- /* for non-cached, or not-yet-cached instances, preload the image */
- if ((cachedInstance == null
- || cachedInstance == newInstance)
+ synchronized (newInstance.backgroundImage.intern()) {
+ /* for non-cached, or not-yet-cached instances, preload the image */
+ if ((cachedInstance == null || cachedInstance == newInstance)
&& !("".equals(newInstance.backgroundImage))) {
- //Additional processing: preload image
- String uri = URISpecification.getURL(newInstance.backgroundImage);
- FObj fobj = pList.getFObj();
- FOUserAgent userAgent = pList.getFObj().getUserAgent();
- ImageManager manager = userAgent.getFactory().getImageManager();
- ImageSessionContext sessionContext = userAgent.getImageSessionContext();
- ImageInfo info;
- try {
- info = manager.getImageInfo(uri, sessionContext);
- newInstance.backgroundImageInfo = info;
- } catch (ImageException e) {
- ResourceEventProducer eventProducer = ResourceEventProducer.Provider.get(
- fobj.getUserAgent().getEventBroadcaster());
- eventProducer.imageError(fobj, uri, e, fobj.getLocator());
- } catch (FileNotFoundException fnfe) {
- ResourceEventProducer eventProducer = ResourceEventProducer.Provider.get(
- fobj.getUserAgent().getEventBroadcaster());
- eventProducer.imageNotFound(fobj, uri, fnfe, fobj.getLocator());
- } catch (IOException ioe) {
- ResourceEventProducer eventProducer = ResourceEventProducer.Provider.get(
- fobj.getUserAgent().getEventBroadcaster());
- eventProducer.imageIOError(fobj, uri, ioe, fobj.getLocator());
+ //Additional processing: preload image
+ String uri = URISpecification.getURL(newInstance.backgroundImage);
+ FObj fobj = pList.getFObj();
+ FOUserAgent userAgent = pList.getFObj().getUserAgent();
+ ImageManager manager = userAgent.getFactory().getImageManager();
+ ImageSessionContext sessionContext = userAgent.getImageSessionContext();
+ ImageInfo info;
+ try {
+ info = manager.getImageInfo(uri, sessionContext);
+ newInstance.backgroundImageInfo = info;
+ } catch (ImageException e) {
+ ResourceEventProducer eventProducer = ResourceEventProducer.Provider.get(
+ fobj.getUserAgent().getEventBroadcaster());
+ eventProducer.imageError(fobj, uri, e, fobj.getLocator());
+ } catch (FileNotFoundException fnfe) {
+ ResourceEventProducer eventProducer = ResourceEventProducer.Provider.get(
+ fobj.getUserAgent().getEventBroadcaster());
+ eventProducer.imageNotFound(fobj, uri, fnfe, fobj.getLocator());
+ } catch (IOException ioe) {
+ ResourceEventProducer eventProducer = ResourceEventProducer.Provider.get(
+ fobj.getUserAgent().getEventBroadcaster());
+ eventProducer.imageIOError(fobj, uri, ioe, fobj.getLocator());
+ }
}
}