diff options
author | Adrian Cumiskey <acumiskey@apache.org> | 2008-11-18 09:57:08 +0000 |
---|---|---|
committer | Adrian Cumiskey <acumiskey@apache.org> | 2008-11-18 09:57:08 +0000 |
commit | 67c82c98fbd59ff04f3556f1b28569958a5e66c6 (patch) | |
tree | 3af15550d9f09622e52e87ebb68b11d54e7d060b /src/java/org | |
parent | 91a223f9a2d6a9a502b293653b39e4d506a245da (diff) | |
download | xmlgraphics-fop-67c82c98fbd59ff04f3556f1b28569958a5e66c6.tar.gz xmlgraphics-fop-67c82c98fbd59ff04f3556f1b28569958a5e66c6.zip |
Merged revisions 718309,718502 via svnmerge from
https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk
........
r718309 | adelmelle | 2008-11-17 18:18:20 +0000 (Mon, 17 Nov 2008) | 4 lines
Bugzilla 46211:
Fixed some multi-threading issues in FontCache.java (+ some minor cleanup: simplification of conditionals)
Thanks to rogov.AT.devexperts.com for tracing and reporting the problem.
........
r718502 | adelmelle | 2008-11-18 06:43:08 +0000 (Tue, 18 Nov 2008) | 1 line
Removed erroneous end-element...
........
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_AFPGOCAResources@718538 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org')
-rw-r--r-- | src/java/org/apache/fop/fonts/FontCache.java | 42 |
1 files changed, 14 insertions, 28 deletions
diff --git a/src/java/org/apache/fop/fonts/FontCache.java b/src/java/org/apache/fop/fonts/FontCache.java index 2528989bb..a3ff1b672 100644 --- a/src/java/org/apache/fop/fonts/FontCache.java +++ b/src/java/org/apache/fop/fonts/FontCache.java @@ -48,7 +48,7 @@ public final class FontCache implements Serializable { * Serialization Version UID. Change this value if you want to make sure the user's cache * file is purged after an update. */ - private static final long serialVersionUID = 605232520271754718L; + private static final long serialVersionUID = 605232520271754719L; /** logging instance */ private static Log log = LogFactory.getLog(FontCache.class); @@ -64,7 +64,7 @@ public final class FontCache implements Serializable { private transient boolean changed = false; /** change lock */ - private transient Object changeLock = new Object(); + private final Object changeLock = new Object(); /** master mapping of font url -> font info. This needs to be * a list, since a TTC file may contain more than 1 font. */ @@ -80,12 +80,6 @@ public final class FontCache implements Serializable { //nop } - private void readObject(java.io.ObjectInputStream in) - throws IOException, ClassNotFoundException { - in.defaultReadObject(); - this.changeLock = new Object(); //Initialize transient field - } - private static File getUserHome() { String s = System.getProperty("user.home"); if (s != null) { @@ -226,10 +220,8 @@ public final class FontCache implements Serializable { * @return boolean */ public boolean containsFont(String embedUrl) { - if (embedUrl != null) { - return getFontFileMap().containsKey(embedUrl); - } - return false; + return (embedUrl != null + && getFontFileMap().containsKey(embedUrl)); } /** @@ -238,10 +230,8 @@ public final class FontCache implements Serializable { * @return font */ public boolean containsFont(EmbedFontInfo fontInfo) { - if (fontInfo != null) { - return getFontFileMap().containsKey(getCacheKey(fontInfo)); - } - return false; + return (fontInfo != null + && getFontFileMap().containsKey(getCacheKey(fontInfo))); } /** @@ -316,10 +306,7 @@ public final class FontCache implements Serializable { * @return CachedFontFile object */ public CachedFontFile getFontFile(String embedUrl) { - if (containsFont(embedUrl)) { - return (CachedFontFile)getFontFileMap().get(embedUrl); - } - return null; + return containsFont(embedUrl) ? (CachedFontFile) getFontFileMap().get(embedUrl) : null; } /** @@ -362,8 +349,8 @@ public final class FontCache implements Serializable { * @return whether this is a failed font */ public boolean isFailedFont(String embedUrl, long lastModified) { - if (getFailedFontMap().containsKey(embedUrl)) { - synchronized (changeLock) { + synchronized (changeLock) { + if (getFailedFontMap().containsKey(embedUrl)) { long failedLastModified = ((Long)getFailedFontMap().get(embedUrl)).longValue(); if (lastModified != failedLastModified) { // this font has been changed so lets remove it @@ -371,10 +358,11 @@ public final class FontCache implements Serializable { getFailedFontMap().remove(embedUrl); changed = true; } + return true; + } else { + return false; } - return true; } - return false; } /** @@ -457,10 +445,8 @@ public final class FontCache implements Serializable { } public boolean containsFont(EmbedFontInfo efi) { - if (efi.getPostScriptName() != null) { - return getFileFontsMap().containsKey(efi.getPostScriptName()); - } - return false; + return efi.getPostScriptName() != null + && getFileFontsMap().containsKey(efi.getPostScriptName()); } public EmbedFontInfo[] getEmbedFontInfos() { |