Summary: FontCache.getDefaultCacheFile() method returns a non-
                    existant file handle
           Product: Fop
           Version: all
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Keywords: PatchAvailable
          Severity: normal
          Priority: P2
         Component: fonts

Created an attachment (id=23243)
 --> (
Patch to FontCache to use a fallback if the user directory is not writable

Method getDefaultCacheFile() returns an invalid file handle because it doesn't
check to see if the directory is writable.

private static File getUserHome() {
        String s = System.getProperty("user.home");
        if (s != null) {
            File userDir = new File(s);
            if (userDir.exists()) {
                return userDir;
        return null;

     * Returns the default font cache file.
     * @param forWriting true if the user directory should be created
     * @return the default font cache file
    public static File getDefaultCacheFile(boolean forWriting) {
        File userHome = getUserHome();
        if (userHome != null) {
            File fopUserDir = new File(userHome, FOP_USER_DIR);
            if (forWriting) {
            return new File(fopUserDir, DEFAULT_CACHE_FILENAME);
        return new File(FOP_USER_DIR);

The method getUserHome() can return a directory that is not a writable
directory. In most cases, the user who is running the webserver has access to
user.home, but some in some environments, it is possible that user.home is not
writable. Anyway, a simple way to fix it would be to fall back to a the if the userHome is not writable. See attached patch that has
that fix

Configure bugmail:
------- You are receiving this mail because: -------
You are the assignee for the bug.

Reply via email to