diff options
author | Simon Steiner <ssteiner@apache.org> | 2022-06-23 13:00:32 +0000 |
---|---|---|
committer | Simon Steiner <ssteiner@apache.org> | 2022-06-23 13:00:32 +0000 |
commit | eeb9f370139fcf24a0e74b8af1408662a08ff779 (patch) | |
tree | 917e5ed84055a09e936c0f9077ddabb47b60fd25 | |
parent | bad28da68ae8ff3a9b530d20648395b626c0c7b9 (diff) | |
download | xmlgraphics-fop-eeb9f370139fcf24a0e74b8af1408662a08ff779.tar.gz xmlgraphics-fop-eeb9f370139fcf24a0e74b8af1408662a08ff779.zip |
FOP-2897: Skip OOM during font OS scanning
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1902203 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | fop-core/src/main/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java | 12 | ||||
-rw-r--r-- | fop-core/src/test/java/org/apache/fop/fonts/FontInfoFinderTestCase.java | 20 |
2 files changed, 26 insertions, 6 deletions
diff --git a/fop-core/src/main/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java b/fop-core/src/main/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java index a7353eb1e..8e5a770be 100644 --- a/fop-core/src/main/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java +++ b/fop-core/src/main/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java @@ -206,10 +206,10 @@ public class FontInfoFinder { if (ttcNames == null) { return null; } - } catch (Exception e) { + } catch (Throwable e) { if (this.eventListener != null) { this.eventListener.fontLoadingErrorAtAutoDetection(this, - fontURI.toASCIIString(), e); + fontURI.toASCIIString(), new RuntimeException(e)); } return null; } finally { @@ -231,13 +231,13 @@ public class FontInfoFinder { if (this.eventListener != null) { customFont.setEventListener(this.eventListener); } - } catch (Exception e) { + } catch (Throwable e) { if (fontCache != null) { fontCache.registerFailedFont(embedUri.toASCIIString(), fileLastModified); } if (this.eventListener != null) { this.eventListener.fontLoadingErrorAtAutoDetection(this, - embedUri.toASCIIString(), e); + embedUri.toASCIIString(), new RuntimeException(e)); } continue; } @@ -258,13 +258,13 @@ public class FontInfoFinder { if (this.eventListener != null) { customFont.setEventListener(this.eventListener); } - } catch (Exception e) { + } catch (Throwable e) { if (fontCache != null) { fontCache.registerFailedFont(embedUri.toASCIIString(), fileLastModified); } if (this.eventListener != null) { this.eventListener.fontLoadingErrorAtAutoDetection(this, - embedUri.toASCIIString(), e); + embedUri.toASCIIString(), new RuntimeException(e)); } return null; } diff --git a/fop-core/src/test/java/org/apache/fop/fonts/FontInfoFinderTestCase.java b/fop-core/src/test/java/org/apache/fop/fonts/FontInfoFinderTestCase.java index 1a7af666f..0b9ad930a 100644 --- a/fop-core/src/test/java/org/apache/fop/fonts/FontInfoFinderTestCase.java +++ b/fop-core/src/test/java/org/apache/fop/fonts/FontInfoFinderTestCase.java @@ -21,12 +21,17 @@ package org.apache.fop.fonts; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; +import java.io.OutputStream; +import java.net.URI; import org.junit.Assert; import org.junit.Test; import org.apache.commons.io.IOUtils; +import org.apache.xmlgraphics.io.Resource; +import org.apache.xmlgraphics.io.ResourceResolver; + import org.apache.fop.apps.io.InternalResourceResolver; import org.apache.fop.apps.io.ResourceResolverFactory; import org.apache.fop.fonts.autodetect.FontInfoFinder; @@ -44,4 +49,19 @@ public class FontInfoFinderTestCase { ttc.delete(); Assert.assertNull(embedFontInfos); } + + @Test + public void testOOMError() { + InternalResourceResolver rr = ResourceResolverFactory.createInternalResourceResolver(new File(".").toURI(), + new ResourceResolver() { + public Resource getResource(URI uri) { + throw new Error(); + } + public OutputStream getOutputStream(URI uri) { + return null; + } + }); + EmbedFontInfo[] embedFontInfos = new FontInfoFinder().find(new File(".").toURI(), rr, null); + Assert.assertNull(embedFontInfos); + } } |