From dev-return-57050-archive-asf-public=cust-asf.ponee.io@pdfbox.apache.org Mon Jun 18 17:48:04 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 F0F6E18067E for ; Mon, 18 Jun 2018 17:48:03 +0200 (CEST) Received: (qmail 27920 invoked by uid 500); 18 Jun 2018 15:48:03 -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 27789 invoked by uid 99); 18 Jun 2018 15:48:02 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 18 Jun 2018 15:48:02 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id 6090C1A2E33 for ; Mon, 18 Jun 2018 15:48:02 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -109.501 X-Spam-Level: X-Spam-Status: No, score=-109.501 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, USER_IN_DEF_SPF_WL=-7.5, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id 0H-fwFyynu0w for ; Mon, 18 Jun 2018 15:48:01 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id 0FF2D5F3CC for ; Mon, 18 Jun 2018 15:48: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 9DF08E0361 for ; Mon, 18 Jun 2018 15:48: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 16A3C21832 for ; Mon, 18 Jun 2018 15:48:00 +0000 (UTC) Date: Mon, 18 Jun 2018 15:48:00 +0000 (UTC) From: "Tilman Hausherr (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= 15911#comment-16515911 ]=20 Tilman Hausherr commented on PDFBOX-4242: ----------------------------------------- Thank you, I'll investigate. This won't be in time for 2.0.10 which is due = for build today. > 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