Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 77B2C200D56 for ; Tue, 12 Dec 2017 19:29:52 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 76276160C00; Tue, 12 Dec 2017 18:29:52 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id BAEBD160BE7 for ; Tue, 12 Dec 2017 19:29:51 +0100 (CET) Received: (qmail 10334 invoked by uid 500); 12 Dec 2017 18:29:50 -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 10325 invoked by uid 99); 12 Dec 2017 18:29:50 -0000 Received: from Unknown (HELO svn01-us-west.apache.org) (209.188.14.144) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 12 Dec 2017 18:29:50 +0000 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 737623A00E7 for ; Tue, 12 Dec 2017 18:29:48 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1817941 - /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfwriter/COSWriter.java Date: Tue, 12 Dec 2017 18:29:46 -0000 To: commits@pdfbox.apache.org From: tilman@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20171212182949.737623A00E7@svn01-us-west.apache.org> archived-at: Tue, 12 Dec 2017 18:29:52 -0000 Author: tilman Date: Tue Dec 12 18:29:46 2017 New Revision: 1817941 URL: http://svn.apache.org/viewvc?rev=1817941&view=rev Log: PDFBOX-2852: simplify code, reformat, change parameter name to be same as other constructor Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfwriter/COSWriter.java Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfwriter/COSWriter.java URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfwriter/COSWriter.java?rev=1817941&r1=1817940&r2=1817941&view=diff ============================================================================== --- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfwriter/COSWriter.java (original) +++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfwriter/COSWriter.java Tue Dec 12 18:29:46 2017 @@ -223,11 +223,11 @@ public class COSWriter implements ICOSVi /** * COSWriter constructor comment. * - * @param os The wrapped output stream. + * @param outputStream The wrapped output stream. */ - public COSWriter(OutputStream os) + public COSWriter(OutputStream outputStream) { - setOutput(os); + setOutput(outputStream); setStandardOutput(new COSStandardOutputStream(output)); } @@ -670,19 +670,17 @@ public class COSWriter implements ICOSVi } /** - * Write an incremental update for a non signature case. This can be used for e.g. augmenting signatures. - * + * Write an incremental update for a non signature case. This can be used for e.g. augmenting + * signatures. + * * @throws IOException */ private void doWriteIncrement() throws IOException { - ByteArrayOutputStream byteOut = (ByteArrayOutputStream) output; - byteOut.flush(); - byte[] buffer = byteOut.toByteArray(); - SequenceInputStream signStream = new SequenceInputStream(new RandomAccessInputStream(incrementalInput), - new ByteArrayInputStream(buffer)); - // write the data to the incremental output stream - IOUtils.copy(signStream, incrementalOutput); + // write existing PDF + IOUtils.copy(new RandomAccessInputStream(incrementalInput), incrementalOutput); + // write the actual incremental update + incrementalOutput.write(((ByteArrayOutputStream) output).toByteArray()); } private void doWriteSignature() throws IOException @@ -1130,14 +1128,16 @@ public class COSWriter implements ICOSVi getStandardOutput().write(EOF); getStandardOutput().writeEOL(); - if(incrementalUpdate) + if (incrementalUpdate) { - if (signatureOffset == 0 || byteRangeOffset == 0) - { - doWriteIncrement(); - } else { - doWriteSignature(); - } + if (signatureOffset == 0 || byteRangeOffset == 0) + { + doWriteIncrement(); + } + else + { + doWriteSignature(); + } } return null;