Return-Path: X-Original-To: apmail-camel-commits-archive@www.apache.org Delivered-To: apmail-camel-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 5C50BD684 for ; Sun, 9 Sep 2012 07:43:17 +0000 (UTC) Received: (qmail 35445 invoked by uid 500); 9 Sep 2012 07:43:17 -0000 Delivered-To: apmail-camel-commits-archive@camel.apache.org Received: (qmail 35330 invoked by uid 500); 9 Sep 2012 07:43:14 -0000 Mailing-List: contact commits-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@camel.apache.org Delivered-To: mailing list commits@camel.apache.org Received: (qmail 35322 invoked by uid 99); 9 Sep 2012 07:43:14 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 09 Sep 2012 07:43:14 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 09 Sep 2012 07:43:09 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 6B84823889D7; Sun, 9 Sep 2012 07:42:26 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1382417 - in /camel/branches/camel-2.10.x: ./ components/camel-crypto/src/main/java/org/apache/camel/converter/crypto/PGPDataFormat.java Date: Sun, 09 Sep 2012 07:42:26 -0000 To: commits@camel.apache.org From: davsclaus@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120909074226.6B84823889D7@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: davsclaus Date: Sun Sep 9 07:42:25 2012 New Revision: 1382417 URL: http://svn.apache.org/viewvc?rev=1382417&view=rev Log: CAMEL-5583: PGP data format should close streams to avoid issues on windwos when reading from files. Thanks to Daniel Gredler for the patch. Modified: camel/branches/camel-2.10.x/ (props changed) camel/branches/camel-2.10.x/components/camel-crypto/src/main/java/org/apache/camel/converter/crypto/PGPDataFormat.java Propchange: camel/branches/camel-2.10.x/ ------------------------------------------------------------------------------ Merged /camel/trunk:r1382416 Propchange: camel/branches/camel-2.10.x/ ------------------------------------------------------------------------------ Binary property 'svnmerge-integrated' - no diff available. Modified: camel/branches/camel-2.10.x/components/camel-crypto/src/main/java/org/apache/camel/converter/crypto/PGPDataFormat.java URL: http://svn.apache.org/viewvc/camel/branches/camel-2.10.x/components/camel-crypto/src/main/java/org/apache/camel/converter/crypto/PGPDataFormat.java?rev=1382417&r1=1382416&r2=1382417&view=diff ============================================================================== --- camel/branches/camel-2.10.x/components/camel-crypto/src/main/java/org/apache/camel/converter/crypto/PGPDataFormat.java (original) +++ camel/branches/camel-2.10.x/components/camel-crypto/src/main/java/org/apache/camel/converter/crypto/PGPDataFormat.java Sun Sep 9 07:42:25 2012 @@ -66,10 +66,15 @@ public class PGPDataFormat implements Da throw new IllegalArgumentException("Public key is null, cannot proceed"); } - InputStream plaintextStream = ExchangeHelper.convertToMandatoryType(exchange, InputStream.class, graph); - - byte[] compressedData = PGPDataFormatUtil.compress(IOUtils.toByteArray(plaintextStream), - PGPLiteralData.CONSOLE, CompressionAlgorithmTags.ZIP); + byte[] plaintextData; + InputStream plaintextStream = null; + try { + plaintextStream = ExchangeHelper.convertToMandatoryType(exchange, InputStream.class, graph); + plaintextData = IOUtils.toByteArray(plaintextStream); + } finally { + IOUtils.closeQuietly(plaintextStream); + } + byte[] compressedData = PGPDataFormatUtil.compress(plaintextData, PGPLiteralData.CONSOLE, CompressionAlgorithmTags.ZIP); if (armored) { outputStream = new ArmoredOutputStream(outputStream); @@ -96,8 +101,14 @@ public class PGPDataFormat implements Da throw new IllegalArgumentException("Private key is null, cannot proceed"); } - InputStream in = new ByteArrayInputStream(IOUtils.toByteArray(encryptedStream)); - in = PGPUtil.getDecoderStream(in); + InputStream in; + try { + byte[] encryptedData = IOUtils.toByteArray(encryptedStream); + InputStream byteStream = new ByteArrayInputStream(encryptedData); + in = PGPUtil.getDecoderStream(byteStream); + } finally { + IOUtils.closeQuietly(encryptedStream); + } PGPObjectFactory pgpF = new PGPObjectFactory(in); PGPEncryptedDataList enc;