Skip to content

Commit 82be485

Browse files
committed
PDFBOX-5660: close input, as suggested by Valery Bokov; refactor; closes #307
git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1929468 13f79535-47bb-0310-9956-ffa450edef68
1 parent bd928e5 commit 82be485

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

pdfbox/src/test/java/org/apache/pdfbox/pdmodel/font/PDFontTest.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ static void setUp()
8484
void testPDFBox988() throws IOException
8585
{
8686
try (PDDocument doc =
87-
Loader.loadPDF(new RandomAccessReadBuffer(PDFontTest.class.getResourceAsStream("F001u_3_7j.pdf"))))
87+
Loader.loadPDF(RandomAccessReadBuffer.createBufferFromStream(
88+
PDFontTest.class.getResourceAsStream("F001u_3_7j.pdf"))))
8889
{
8990
PDFRenderer renderer = new PDFRenderer(doc);
9091
renderer.renderImage(0);
@@ -184,9 +185,10 @@ void testPDFBOX4115() throws IOException
184185
try (PDDocument doc = new PDDocument())
185186
{
186187
PDPage page = new PDPage();
187-
try (PDPageContentStream contentStream = new PDPageContentStream(doc, page))
188+
try (PDPageContentStream contentStream = new PDPageContentStream(doc, page);
189+
InputStream is = new FileInputStream(fontFile))
188190
{
189-
PDType1Font font = new PDType1Font(doc, new FileInputStream(fontFile), WinAnsiEncoding.INSTANCE);
191+
PDType1Font font = new PDType1Font(doc, is, WinAnsiEncoding.INSTANCE);
190192

191193
contentStream.beginText();
192194
contentStream.setFont(font, 10);

0 commit comments

Comments
 (0)