Return-Path: X-Original-To: apmail-pdfbox-commits-archive@www.apache.org Delivered-To: apmail-pdfbox-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id BCF5A17C69 for ; Mon, 28 Sep 2015 13:23:55 +0000 (UTC) Received: (qmail 81712 invoked by uid 500); 28 Sep 2015 13:23:55 -0000 Delivered-To: apmail-pdfbox-commits-archive@pdfbox.apache.org Received: (qmail 81689 invoked by uid 500); 28 Sep 2015 13:23:55 -0000 Mailing-List: contact commits-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 commits@pdfbox.apache.org Received: (qmail 81680 invoked by uid 99); 28 Sep 2015 13:23:55 -0000 Received: from Unknown (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 28 Sep 2015 13:23:55 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 35BADC69CD for ; Mon, 28 Sep 2015 13:23:55 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.79 X-Spam-Level: * X-Spam-Status: No, score=1.79 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, T_RP_MATCHES_RCVD=-0.01] autolearn=disabled Received: from mx1-eu-west.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id labybTD0aQL9 for ; Mon, 28 Sep 2015 13:23:54 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-eu-west.apache.org (ASF Mail Server at mx1-eu-west.apache.org) with ESMTP id 6F8E620515 for ; Mon, 28 Sep 2015 13:23:53 +0000 (UTC) Received: from svn01-us-west.apache.org (svn.apache.org [10.41.0.6]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 8FDE3E0281 for ; Mon, 28 Sep 2015 13:23:52 +0000 (UTC) Received: from svn01-us-west.apache.org (localhost [127.0.0.1]) by svn01-us-west.apache.org (ASF Mail Server at svn01-us-west.apache.org) with ESMTP id 769633A04B9 for ; Mon, 28 Sep 2015 13:23:52 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1705688 - in /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox: cos/COSDocument.java io/ScratchFile.java pdfparser/FDFParser.java Date: Mon, 28 Sep 2015 13:23:52 -0000 To: commits@pdfbox.apache.org From: tboehme@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20150928132352.769633A04B9@svn01-us-west.apache.org> Author: tboehme Date: Mon Sep 28 13:23:52 2015 New Revision: 1705688 URL: http://svn.apache.org/viewvc?rev=1705688&view=rev Log: PDFBOX-2883: remove COSDocument constructors using boolean 'useScratchFiles' parameter and ensure to have an equivalent constructor using MemoryUsageSetting object; default is using main memory only (as before) Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSDocument.java pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/io/ScratchFile.java pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/FDFParser.java Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSDocument.java URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSDocument.java?rev=1705688&r1=1705687&r2=1705688&view=diff ============================================================================== --- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSDocument.java (original) +++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSDocument.java Mon Sep 28 13:23:52 2015 @@ -17,12 +17,12 @@ package org.apache.pdfbox.cos; import java.io.Closeable; -import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.pdfbox.io.ScratchFile; @@ -79,46 +79,18 @@ public class COSDocument extends COSBase private ScratchFile scratchFile; /** - * Constructor. - * - * @param useScratchFiles enables the usage of a scratch file if set to true - * - */ - public COSDocument(boolean useScratchFiles) - { - this((File)null, useScratchFiles); - } - - /** - * Constructor that will use a temporary file in the given directory - * for storage of the PDF streams. The temporary file is automatically - * removed when this document gets closed. - * - * @param scratchDir directory for the temporary file, - * or null to use the system default - * @param useScratchFiles enables the usage of a scratch file if set to true - * + * Constructor. Uses main memory to buffer PDF streams. */ - public COSDocument(File scratchDir, boolean useScratchFiles) + public COSDocument() { - if (useScratchFiles) - { - try - { - scratchFile = new ScratchFile(scratchDir); - } - catch (IOException e) - { - LOG.error("Can't create temp file, using memory buffer instead", e); - } - } + this(ScratchFile.getMainMemoryOnlyInstance()); } /** * Constructor that will use the provide memory handler for storage of the * PDF streams. * - * @param scratchFile memory handler for storage of PDF streams + * @param scratchFile memory handler for buffering of PDF streams * */ public COSDocument(ScratchFile scratchFile) @@ -127,14 +99,6 @@ public class COSDocument extends COSBase } /** - * Constructor. Uses memory to store stream. - */ - public COSDocument() - { - this(false); - } - - /** * Creates a new COSStream using the current configuration for scratch files. * * @return the new COSStream @@ -169,7 +133,7 @@ public class COSDocument extends COSBase * @return This will return an object with the specified type. * @throws IOException If there is an error getting the object */ - public COSObject getObjectByType( COSName type ) throws IOException + public COSObject getObjectByType(COSName type) throws IOException { for( COSObject object : objectPool.values() ) { Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/io/ScratchFile.java URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/io/ScratchFile.java?rev=1705688&r1=1705687&r2=1705688&view=diff ============================================================================== --- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/io/ScratchFile.java (original) +++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/io/ScratchFile.java Mon Sep 28 13:23:52 2015 @@ -135,12 +135,19 @@ public class ScratchFile implements Clos * (same as new ScratchFile(MemoryUsageSetting.setupMainMemoryOnly())). * * @return instance configured to only use main memory with no size restriction - * - * @throws IOException */ - public static ScratchFile getMainMemoryOnlyInstance() throws IOException + public static ScratchFile getMainMemoryOnlyInstance() { - return new ScratchFile(MemoryUsageSetting.setupMainMemoryOnly()); + try + { + return new ScratchFile(MemoryUsageSetting.setupMainMemoryOnly()); + } + catch (IOException ioe) + { + // cannot happen for main memory setup + LOG.error("Unexpected exception occurred creating main memory scratch file instance: " + ioe.getMessage() ); + return null; + } } /** Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/FDFParser.java URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/FDFParser.java?rev=1705688&r1=1705687&r2=1705688&view=diff ============================================================================== --- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/FDFParser.java (original) +++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/FDFParser.java Mon Sep 28 13:23:52 2015 @@ -89,7 +89,7 @@ public class FDFParser extends COSParser + " does not contain an integer value, but: '" + eofLookupRangeStr + "'"); } } - document = new COSDocument(false); + document = new COSDocument(); } /**