You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-dev@xmlgraphics.apache.org by bu...@apache.org on 2009/02/10 00:33:39 UTC

DO NOT REPLY [Bug 46686] New: FontCache.getDefaultCacheFile() method returns a non-existant file handle

https://issues.apache.org/bugzilla/show_bug.cgi?id=46686

           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
        AssignedTo: fop-dev@xmlgraphics.apache.org
        ReportedBy: alok@jivesoftware.com
                CC: alok@jivesoftware.com


Created an attachment (id=23243)
 --> (https://issues.apache.org/bugzilla/attachment.cgi?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.
{code}

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) {
                fopUserDir.mkdir();
            }
            return new File(fopUserDir, DEFAULT_CACHE_FILENAME);
        }
        return new File(FOP_USER_DIR);

}
{code}
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
java.io.tmpdir if the userHome is not writable. See attached patch that has
that fix


-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

DO NOT REPLY [Bug 46686] [PATCH] FontCache.getDefaultCacheFile() method returns a non-existant file handle

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=46686

Glenn Adams <gl...@skynav.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |CLOSED

--- Comment #2 from Glenn Adams <gl...@skynav.com> 2012-04-01 07:09:02 UTC ---
batch transition pre-FOP1.0 resolved+fixed bugs to closed+fixed

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

DO NOT REPLY [Bug 46686] [PATCH] FontCache.getDefaultCacheFile() method returns a non-existant file handle

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=46686


Jeremias Maerki <je...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED




--- Comment #1 from Jeremias Maerki <je...@apache.org>  2009-02-11 00:42:58 PST ---
Thanks for the patch. I've applied it with modifications:
http://svn.apache.org/viewvc?rev=743273&view=rev

The problem was that your code didn't handle the case correctly that the font
cache already existed in the user home. It always switched to the temporary
directory. I've also had trouble automatically applying the patch. Not sure
what was wrong. Had to do it manually.


-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

DO NOT REPLY [Bug 46686] [PATCH] FontCache.getDefaultCacheFile() method returns a non-existant file handle

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=46686


Jeremias Maerki <je...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
            Summary|FontCache.getDefaultCacheFil|[PATCH]
                   |e() method returns a non-   |FontCache.getDefaultCacheFil
                   |existant file handle        |e() method returns a non-
                   |                            |existant file handle




-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.