Author: jahewson Date: Tue Dec 1 20:41:04 2015 New Revision: 1717521 URL: http://svn.apache.org/viewvc?rev=1717521&view=rev Log: PDFBOX-3145: Log error if file system cannot be read/written
Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/FileSystemFontProvider.java Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/FileSystemFontProvider.java URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/FileSystemFontProvider.java?rev=1717521&r1=1717520&r2=1717521&view=diff ============================================================================== --- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/FileSystemFontProvider.java (original) +++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/FileSystemFontProvider.java Tue Dec 1 20:41:04 2015 @@ -26,6 +26,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.Serializable; import java.net.URI; +import java.security.AccessControlException; import java.util.ArrayList; import java.util.HashSet; import java.util.List; @@ -192,39 +193,45 @@ final class FileSystemFontProvider exten FileSystemFontProvider(FontCache cache) { this.cache = cache; - - if (LOG.isTraceEnabled()) + try { - LOG.trace("Will search the local system for fonts"); - } + if (LOG.isTraceEnabled()) + { + LOG.trace("Will search the local system for fonts"); + } - // scan the local system for font files - List<File> files = new ArrayList<File>(); - FontFileFinder fontFileFinder = new FontFileFinder(); - List<URI> fonts = fontFileFinder.find(); - for (URI font : fonts) - { - files.add(new File(font)); - } + // scan the local system for font files + List<File> files = new ArrayList<File>(); + FontFileFinder fontFileFinder = new FontFileFinder(); + List<URI> fonts = fontFileFinder.find(); + for (URI font : fonts) + { + files.add(new File(font)); + } - if (LOG.isTraceEnabled()) - { - LOG.trace("Found " + files.size() + " fonts on the local system"); - } - - // load cached FontInfo objects - List<FSFontInfo> cachedInfos = loadDiskCache(files); - if (cachedInfos != null && cachedInfos.size() > 0) - { - fontInfoList.addAll(cachedInfos); + if (LOG.isTraceEnabled()) + { + LOG.trace("Found " + files.size() + " fonts on the local system"); + } + + // load cached FontInfo objects + List<FSFontInfo> cachedInfos = loadDiskCache(files); + if (cachedInfos != null && cachedInfos.size() > 0) + { + fontInfoList.addAll(cachedInfos); + } + else + { + LOG.warn("Building on-disk font cache, this may take a while"); + scanFonts(files); + saveDiskCache(); + LOG.warn("Finished building on-disk font cache, found " + + fontInfoList.size() + " fonts"); + } } - else + catch (AccessControlException e) { - LOG.warn("Building on-disk font cache, this may take a while"); - scanFonts(files); - saveDiskCache(); - LOG.warn("Finished building on-disk font cache, found " + - fontInfoList.size() + " fonts"); + LOG.error("Error accessing the file system", e); } }