Browse Source

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
tags/fop-2_8
Simon Steiner 1 year ago
parent
commit
eeb9f37013

+ 6
- 6
fop-core/src/main/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java View File

@@ -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;
}

+ 20
- 0
fop-core/src/test/java/org/apache/fop/fonts/FontInfoFinderTestCase.java View File

@@ -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);
}
}

Loading…
Cancel
Save