From dev-return-57307-archive-asf-public=cust-asf.ponee.io@pdfbox.apache.org Wed Jul 4 20:23:05 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 088B0180674 for ; Wed, 4 Jul 2018 20:23:04 +0200 (CEST) Received: (qmail 17237 invoked by uid 500); 4 Jul 2018 18:23:04 -0000 Mailing-List: contact dev-help@pdfbox.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@pdfbox.apache.org Delivered-To: mailing list dev@pdfbox.apache.org Received: (qmail 17225 invoked by uid 99); 4 Jul 2018 18:23:04 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 04 Jul 2018 18:23:04 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 90910186560 for ; Wed, 4 Jul 2018 18:23:03 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -109.511 X-Spam-Level: X-Spam-Status: No, score=-109.511 tagged_above=-999 required=6.31 tests=[ENV_AND_HDR_SPF_MATCH=-0.5, KAM_ASCII_DIVIDERS=0.8, RCVD_IN_DNSWL_MED=-2.3, SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01, USER_IN_DEF_SPF_WL=-7.5, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id 5bGFoIMIH8Zc for ; Wed, 4 Jul 2018 18:23:02 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTP id 9100E5F23E for ; Wed, 4 Jul 2018 18:23:01 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id AA3E0E00FF for ; Wed, 4 Jul 2018 18:23:00 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 24C6E274F8 for ; Wed, 4 Jul 2018 18:23:00 +0000 (UTC) Date: Wed, 4 Jul 2018 18:23:00 +0000 (UTC) From: "ASF subversion and git services (JIRA)" To: dev@pdfbox.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (PDFBOX-4242) Fontbox does not close file descriptor when loading fonts. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/PDFBOX-4242?page=3Dcom.atlassia= n.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=3D165= 32998#comment-16532998 ]=20 ASF subversion and git services commented on PDFBOX-4242: --------------------------------------------------------- Commit 1835076 from tilman@apache.org in branch 'pdfbox/trunk' [ https://svn.apache.org/r1835076 ] PDFBOX-4242: register fonts and close them when closing the document to avo= id memory leaks > Fontbox does not close file descriptor when loading fonts. > ---------------------------------------------------------- > > Key: PDFBOX-4242 > URL: https://issues.apache.org/jira/browse/PDFBOX-4242 > Project: PDFBox > Issue Type: Bug > Components: FontBox > Affects Versions: 2.0.9 > Reporter: Glen Peterson > Priority: Minor > Labels: file_leak > > My app has been getting "java.io.FileNotFoundException (No file descripto= rs available)" and I've confirmed that=C2=A0it's because fontbox isn't clos= ing it's file descriptors. > In=C2=A0org.apache.fontbox.ttf.TTFParser there's this method: > {{public TrueTypeFont parse(File ttfFile) throws IOException {}} > {{=C2=A0 RAFDataStream raf =3D new RAFDataStream(ttfFile, "r");}} > {{=C2=A0 try {}} > {{=C2=A0 =C2=A0 return this.parse((TTFDataStream)raf);}} > {{=C2=A0 } catch (IOException var4) {}} > {{=C2=A0 =C2=A0 // close only on error (file is still being accessed lat= er)}} > {{=C2=A0 =C2=A0 raf.close();}} > {{=C2=A0 =C2=A0 throw var4;}} > {{}}} > {{}}} > I would have expected to see the close() in a finally block so that the f= ile is always closed, not just on exceptions. Presumably, you can keep it i= n memory without leaving the file descriptor open? > {{public TrueTypeFont parse(File ttfFile) throws IOException {}} > {{=C2=A0 RAFDataStream raf =3D new RAFDataStream(ttfFile, "r");}} > {{=C2=A0 try {}} > {{=C2=A0 =C2=A0 return this.parse((TTFDataStream)raf);}} > {{=C2=A0 } catch (IOException var4) {}}{{=C2=A0 =C2=A0 raf.close();}} > {{=C2=A0 =C2=A0 throw var4;}} > {{=C2=A0 } finally {}} > {{=C2=A0 =C2=A0 raf.close();}} > {{}}} > {{}}} > I tried performing this in a lazy initialization, but it blew up: > java.lang.RuntimeException: java.io.IOException: The TrueType font null d= oes not contain a 'cmap' tableCaused by: java.io.IOException: The TrueType = font null does not contain a 'cmap' table > at org.apache.fontbox.ttf.TrueTypeFont.getUnicodeCmapImpl(TrueTypeFont.= java:548) > at org.apache.fontbox.ttf.TrueTypeFont.getUnicodeCmapLookup(TrueTypeFon= t.java:528) > at org.apache.fontbox.ttf.TrueTypeFont.getUnicodeCmapLookup(TrueTypeFon= t.java:514) > at org.apache.fontbox.ttf.TTFSubsetter.(TTFSubsetter.java:91) > at org.apache.pdfbox.pdmodel.font.TrueTypeEmbedder.subset(TrueTypeEmbed= der.java:321) > at org.apache.pdfbox.pdmodel.font.PDType0Font.subset(PDType0Font.java:2= 39) > at org.apache.pdfbox.pdmodel.PDDocument.save(PDDocument.java:1271) > Thoughts? > Thanks for PDFBox - it's been really helpful! -- This message was sent by Atlassian JIRA (v7.6.3#76005) --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@pdfbox.apache.org For additional commands, e-mail: dev-help@pdfbox.apache.org