[jira] [Commented] (FOP-2954) Uncaught java.lang.ClassCastException in FontCache.loadFrom()

2022-04-22 Thread J Frank (Jira)


[ 
https://issues.apache.org/jira/browse/FOP-2954?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17526325#comment-17526325
 ] 

J Frank commented on FOP-2954:
--

I would keep the cache as it may slow down the pdf generation, idea is to 
compare both with and without cache

Suggestion: keep the check  outside fop as this is one time failure.

another idea check font cache is not corrupted before generating fop, for that  
we need to know how to replicate the issue.

 

> Uncaught java.lang.ClassCastException in FontCache.loadFrom()
> -
>
> Key: FOP-2954
> URL: https://issues.apache.org/jira/browse/FOP-2954
> Project: FOP
>  Issue Type: Bug
>  Components: font/unqualified
>Affects Versions: 2.4
>Reporter: Jörg Weske
>Priority: Major
> Attachments: stacktrace.txt
>
>
> In certain cases, de-serialization of a defective fontcache file can fail 
> with a java.lang.ClassCastException (see attached partial stacktrace).
> The exception should be caught inside FontCache.loadFrom() and the defective 
> cache file discarded, as with the two other exceptions that are already being 
> handled appropriately (ClassNotFoundException and IOException).



--
This message was sent by Atlassian Jira
(v8.20.7#820007)


[jira] [Commented] (FOP-2954) Uncaught java.lang.ClassCastException in FontCache.loadFrom()

2022-04-21 Thread Simon Steiner (Jira)


[ 
https://issues.apache.org/jira/browse/FOP-2954?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17525955#comment-17525955
 ] 

Simon Steiner commented on FOP-2954:


createRestrictedIO will avoid the font cache:
FopFactoryBuilder confBuilder = new FopConfParser(new 
ByteArrayInputStream(fopxconf.getBytes()),
EnvironmentalProfileFactory.createRestrictedIO(new 
File(".").toURI(), cloudResourceResolver)).getFopFactoryBuilder();
FopFactory fopFactory = confBuilder.build();



> Uncaught java.lang.ClassCastException in FontCache.loadFrom()
> -
>
> Key: FOP-2954
> URL: https://issues.apache.org/jira/browse/FOP-2954
> Project: FOP
>  Issue Type: Bug
>  Components: font/unqualified
>Affects Versions: 2.4
>Reporter: Jörg Weske
>Priority: Major
> Attachments: stacktrace.txt
>
>
> In certain cases, de-serialization of a defective fontcache file can fail 
> with a java.lang.ClassCastException (see attached partial stacktrace).
> The exception should be caught inside FontCache.loadFrom() and the defective 
> cache file discarded, as with the two other exceptions that are already being 
> handled appropriately (ClassNotFoundException and IOException).



--
This message was sent by Atlassian Jira
(v8.20.7#820007)


[jira] [Commented] (FOP-2954) Uncaught java.lang.ClassCastException in FontCache.loadFrom()

2022-04-21 Thread Jira


[ 
https://issues.apache.org/jira/browse/FOP-2954?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17525766#comment-17525766
 ] 

Jörg Weske commented on FOP-2954:
-

Unfortunately, I cannot provide further resources as the problem happened 
onsite at one of our customers and they manually deleted the cache file to 
resolve the issue. We have been unable to successfully manipulate font cache 
files to reproduce the error using a hex editor or by replacing / truncating 
said files.

Manual removal of a defective file is no option in a production environment, as 
our users do not have any direct access to the server running our application 
and would have to raise a (potentially costly) ticket with their respective 
service providers to have the cache file deleted.

Catching the error in our own code from outside FOP and trying to resolve the 
problem by actively deleting the FOP fontcache on a mere hunch does not seem 
like an ideal solution.

Currently, we are using the following workaround:
{code:java}
  public static void clearFontCache() {
    File fontCacheFile = null;
    try {
      fontCacheFile = FontCache.getDefaultCacheFile(false);
      FontCache.loadFrom(fontCacheFile);
    } catch (Throwable ex) {
      if (fontCacheFile != null) {
        log(Level.WARNING, "Deleting defective FOP FontCache file.");
        try {
          fontCacheFile.delete();
        } catch (SecurityException warn) {
          log(Level.WARNING, "Could not delete defective FOP FontCache file \"" 
+ fontCacheFile.getAbsolutePath()
              + "\". Please remove manually.");
        }
      }
    }
  }

try {
   // create FOP file...
} catch (Throwable e) {
  if (e instanceof ClassCastException || e instanceof NoClassDefFoundError) {
    clearFontCache();
  }
  throw new CreatePdfFileException(e);
} {code}
PDF creation will still fail if a defective cache file is first encountered, 
but should work when retrying.

> Uncaught java.lang.ClassCastException in FontCache.loadFrom()
> -
>
> Key: FOP-2954
> URL: https://issues.apache.org/jira/browse/FOP-2954
> Project: FOP
>  Issue Type: Bug
>  Components: font/unqualified
>Affects Versions: 2.4
>Reporter: Jörg Weske
>Priority: Major
> Attachments: stacktrace.txt
>
>
> In certain cases, de-serialization of a defective fontcache file can fail 
> with a java.lang.ClassCastException (see attached partial stacktrace).
> The exception should be caught inside FontCache.loadFrom() and the defective 
> cache file discarded, as with the two other exceptions that are already being 
> handled appropriately (ClassNotFoundException and IOException).



--
This message was sent by Atlassian Jira
(v8.20.7#820007)


[jira] [Commented] (FOP-2954) Uncaught java.lang.ClassCastException in FontCache.loadFrom()

2022-04-21 Thread J Frank (Jira)


[ 
https://issues.apache.org/jira/browse/FOP-2954?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17525727#comment-17525727
 ] 

J Frank commented on FOP-2954:
--

After going through code: my suggestion will be delete cache files from 
user.home and then try loading font file / try generating docs

> Uncaught java.lang.ClassCastException in FontCache.loadFrom()
> -
>
> Key: FOP-2954
> URL: https://issues.apache.org/jira/browse/FOP-2954
> Project: FOP
>  Issue Type: Bug
>  Components: font/unqualified
>Affects Versions: 2.4
>Reporter: Jörg Weske
>Priority: Major
> Attachments: stacktrace.txt
>
>
> In certain cases, de-serialization of a defective fontcache file can fail 
> with a java.lang.ClassCastException (see attached partial stacktrace).
> The exception should be caught inside FontCache.loadFrom() and the defective 
> cache file discarded, as with the two other exceptions that are already being 
> handled appropriately (ClassNotFoundException and IOException).



--
This message was sent by Atlassian Jira
(v8.20.7#820007)


[jira] [Commented] (FOP-2954) Uncaught java.lang.ClassCastException in FontCache.loadFrom()

2022-04-21 Thread J Frank (Jira)


[ 
https://issues.apache.org/jira/browse/FOP-2954?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17525630#comment-17525630
 ] 

J Frank commented on FOP-2954:
--

Can you please share more resources to reproduce the issue ?

> Uncaught java.lang.ClassCastException in FontCache.loadFrom()
> -
>
> Key: FOP-2954
> URL: https://issues.apache.org/jira/browse/FOP-2954
> Project: FOP
>  Issue Type: Bug
>  Components: font/unqualified
>Affects Versions: 2.4
>Reporter: Jörg Weske
>Priority: Major
> Attachments: stacktrace.txt
>
>
> In certain cases, de-serialization of a defective fontcache file can fail 
> with a java.lang.ClassCastException (see attached partial stacktrace).
> The exception should be caught inside FontCache.loadFrom() and the defective 
> cache file discarded, as with the two other exceptions that are already being 
> handled appropriately (ClassNotFoundException and IOException).



--
This message was sent by Atlassian Jira
(v8.20.7#820007)