[
https://issues.apache.org/jira/browse/FOP-2146?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17099923#comment-17099923
]
Jukka Matilainen edited comment on FOP-2146 at 5/5/20, 3:10 PM:
----------------------------------------------------------------
I have the same problem when running on AWS Lambda.
{{FontCache.getUserHome()}} returns {{null}} if the {{user.home}} system
property is unset or the directory pointed to by it does not exist. The latter
seems to be the case on the AWS Lambda Java runtime.
This leads to {{FontCache.getDefaultCacheFile(true)}} returning ".fop" as the
font-cache location, which does not work (instead of the expeced
"/tmp/.fop/fop-fonts.cache" which would work and is what would be returned if
the home directory existed but was read-only).
The problem is that ".fop" won't work as the writable font cache location on
AWS Lambda, since the current working directory is read-only. In fact /tmp
(java.io.tmpdir) directory is the only writable location.
was (Author: jkmatila):
{{FontCache.getUserHome()}} returns {{null}} if the {{user.home}} system
property is unset or the directory pointed to by it does not exist. The latter
seems to be the case on the AWS Lambda Java runtime.
> Wrong FontCache-Directory used for not existing userHome in
> FontCache.getDefaultCacheFile() (Bug 47786 was not fixed correctly)
> -------------------------------------------------------------------------------------------------------------------------------
>
> Key: FOP-2146
> URL: https://issues.apache.org/jira/browse/FOP-2146
> Project: FOP
> Issue Type: Bug
> Components: font/unqualified
> Affects Versions: 1.1
> Environment: Operating System: All
> Platform: All
> Reporter: mg
>
> Method getDefaultCacheFile() returns an invalid file name if the user has no
> home directory set. In that case the name of the fop user directory
> (FOP_USER_DIR!) is returned and not the name of the cache file
> (DEFAULT_CACHE_FILENAME).
> Wrong Code:
> public static File getDefaultCacheFile(boolean forWriting) {
> File userHome = getUserHome();
> if (userHome != null) {
> File fopUserDir = new File(userHome, FOP_USER_DIR);
> if (forWriting) {
> boolean writable = fopUserDir.canWrite();
> if (!fopUserDir.exists()) {
> writable = fopUserDir.mkdir();
> }
> if (!writable) {
> userHome = getTempDirectory();
> fopUserDir = new File(userHome, FOP_USER_DIR);
> fopUserDir.mkdir();
> }
> }
> return new File(fopUserDir, DEFAULT_CACHE_FILENAME);
> }
> return new File(FOP_USER_DIR);
> }
> If getUserHome() does not return a directory the default name must be
> returned (and not the name of the directory):
> return new File(DEFAULT_CACHE_FILENAME);
--
This message was sent by Atlassian Jira
(v8.3.4#803005)