summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fop-core/src/main/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java12
-rw-r--r--fop-core/src/test/java/org/apache/fop/fonts/FontInfoFinderTestCase.java20
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);
+ }
}