This is an automated email from the ASF dual-hosted git repository.

tallison pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tika.git

The following commit(s) were added to refs/heads/master by this push:
       new  9f4bb56   TIKA-2370: avoid potential resource leak by closing 
TrueTypeFont via Cameron Rollheiser.  This closes #181.  I removed the unit 
test based on Cameron's advice.
9f4bb56 is described below

commit 9f4bb56b7a8e2db8d5d60003531f6341563a8ee5
Author: tballison <[email protected]>
AuthorDate: Thu May 18 06:22:10 2017 -0400

    TIKA-2370: avoid potential resource leak by closing TrueTypeFont via
    Cameron Rollheiser.  This closes #181.  I removed the unit test
    based on Cameron's advice.
---
 CHANGES.txt                                        |  3 ++
 .../apache/tika/parser/font/FontParsersTest.java   | 36 ----------------------
 2 files changed, 3 insertions(+), 36 deletions(-)

diff --git a/CHANGES.txt b/CHANGES.txt
index 7ca2cd3..3bb490e 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -116,6 +116,9 @@ Release 1.15 - ??
   * Extend support for increased PSM options up to 13 for modern 
     versions of Tesseract (TIKA-2357).
 
+  * Prevent potential resource leak by closing TrueTypeFont
+    via Cameron Rollheiser (TIKA-2370).
+
 Release 1.14 - 10/19/2016
 
   * Extract all headers from MSG/RFC822 (TIKA-2122).
diff --git 
a/tika-parsers/src/test/java/org/apache/tika/parser/font/FontParsersTest.java 
b/tika-parsers/src/test/java/org/apache/tika/parser/font/FontParsersTest.java
index c01a152..cb95b72 100644
--- 
a/tika-parsers/src/test/java/org/apache/tika/parser/font/FontParsersTest.java
+++ 
b/tika-parsers/src/test/java/org/apache/tika/parser/font/FontParsersTest.java
@@ -113,40 +113,4 @@ public class FontParsersTest {
         String content = handler.toString();
         assertEquals("", content);
     }
-
-    @Test
-    public void testTTFParsingNoLeaks() throws Exception {
-        Parser parser = new AutoDetectParser(); // Should auto-detect!
-        ContentHandler handler = new BodyContentHandler();
-        Metadata metadata = new Metadata();
-        ParseContext context = new ParseContext();
-
-        // Attempt to detect file leaks on unix systems.
-        OperatingSystemMXBean os = 
ManagementFactory.getOperatingSystemMXBean();
-        if (MethodUtils.getMatchingAccessibleMethod(os.getClass(), 
"getOpenFileDescriptorCount", null) == null) {
-            return;
-        }
-
-        // Clone the font to a temporary file on disk, was having trouble 
reliably reproducing the leak with resources.
-        InputStream input = 
FontParsersTest.class.getResourceAsStream("/test-documents/testTrueType3.ttf");
-        Path tempDir = Files.createTempDirectory("fonts");
-        Path tempFont = tempDir.resolve("testTrueType3.ttf");
-        Files.copy(input, tempFont);
-        input.close();
-
-        // Record the expected file handle count.
-        long initialFileCount = (long)MethodUtils.invokeMethod(os, 
"getOpenFileDescriptorCount", null);
-        try (TikaInputStream stream = TikaInputStream.get(tempFont)) {
-            parser.parse(stream, handler, metadata, context);
-        }
-
-        // Check is any file handles leaked.
-        long finalFileCount = (long)MethodUtils.invokeMethod(os, 
"getOpenFileDescriptorCount", null);
-        if (initialFileCount != finalFileCount) {
-            fail("File leak detected. " + initialFileCount + " " + 
finalFileCount);
-        }
-
-        // Clean up temporary files.
-        FileUtils.deleteQuietly(tempDir.toFile());
-    }
 }

-- 
To stop receiving notification emails like this one, please contact
['"[email protected]" <[email protected]>'].

Reply via email to