Return-Path: X-Original-To: apmail-hadoop-common-commits-archive@www.apache.org Delivered-To: apmail-hadoop-common-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 35A8418B6A for ; Fri, 14 Aug 2015 16:13:59 +0000 (UTC) Received: (qmail 23746 invoked by uid 500); 14 Aug 2015 16:13:51 -0000 Delivered-To: apmail-hadoop-common-commits-archive@hadoop.apache.org Received: (qmail 23572 invoked by uid 500); 14 Aug 2015 16:13:51 -0000 Mailing-List: contact common-commits-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: common-dev@hadoop.apache.org Delivered-To: mailing list common-commits@hadoop.apache.org Received: (qmail 21629 invoked by uid 99); 14 Aug 2015 16:13:49 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 14 Aug 2015 16:13:49 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id B068DE1810; Fri, 14 Aug 2015 16:13:49 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: aajisaka@apache.org To: common-commits@hadoop.apache.org Date: Fri, 14 Aug 2015 16:13:59 -0000 Message-Id: <41641b989651402f9f86f820f03d9a83@git.apache.org> In-Reply-To: <8ed7e36fc9c74385abdddf62a48886a6@git.apache.org> References: <8ed7e36fc9c74385abdddf62a48886a6@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [11/18] hadoop git commit: HADOOP-11710. Make CryptoOutputStream behave like DFSOutputStream wrt synchronization. (Sean Busbey via yliu) HADOOP-11710. Make CryptoOutputStream behave like DFSOutputStream wrt synchronization. (Sean Busbey via yliu) (cherry picked from commit 813c93cb250d6d556604fe98845b979970bd5e18) Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/f53cf674 Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/f53cf674 Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/f53cf674 Branch: refs/heads/ajisakaa/common-merge Commit: f53cf6742f836e06eb4dc26996169c2babc149ee Parents: 2f8d46c Author: yliu Authored: Fri Mar 13 02:26:16 2015 +0800 Committer: Akira Ajisaka Committed: Fri Aug 14 01:08:53 2015 +0900 ---------------------------------------------------------------------- hadoop-common-project/hadoop-common/CHANGES.txt | 3 +++ .../apache/hadoop/crypto/CryptoOutputStream.java | 19 ++++++++++++------- 2 files changed, 15 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hadoop/blob/f53cf674/hadoop-common-project/hadoop-common/CHANGES.txt ---------------------------------------------------------------------- diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt index e7ba2af..c952f54 100644 --- a/hadoop-common-project/hadoop-common/CHANGES.txt +++ b/hadoop-common-project/hadoop-common/CHANGES.txt @@ -46,6 +46,9 @@ Release 2.6.1 - UNRELEASED HADOOP-11674. oneByteBuf in CryptoInputStream and CryptoOutputStream should be non static. (Sean Busbey via yliu) + HADOOP-11710. Make CryptoOutputStream behave like DFSOutputStream wrt + synchronization. (Sean Busbey via yliu) + Release 2.6.0 - 2014-11-18 INCOMPATIBLE CHANGES http://git-wip-us.apache.org/repos/asf/hadoop/blob/f53cf674/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/crypto/CryptoOutputStream.java ---------------------------------------------------------------------- diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/crypto/CryptoOutputStream.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/crypto/CryptoOutputStream.java index f1b2737..9e79fbf 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/crypto/CryptoOutputStream.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/crypto/CryptoOutputStream.java @@ -40,6 +40,9 @@ import com.google.common.base.Preconditions; * padding = pos%(algorithm blocksize); *

* The underlying stream offset is maintained as state. + * + * Note that while some of this class' methods are synchronized, this is just to + * match the threadsafety behavior of DFSOutputStream. See HADOOP-11710. */ @InterfaceAudience.Private @InterfaceStability.Evolving @@ -125,7 +128,7 @@ public class CryptoOutputStream extends FilterOutputStream implements * @throws IOException */ @Override - public void write(byte[] b, int off, int len) throws IOException { + public synchronized void write(byte[] b, int off, int len) throws IOException { checkStream(); if (b == null) { throw new NullPointerException(); @@ -212,14 +215,16 @@ public class CryptoOutputStream extends FilterOutputStream implements } @Override - public void close() throws IOException { + public synchronized void close() throws IOException { if (closed) { return; } - - super.close(); - freeBuffers(); - closed = true; + try { + super.close(); + freeBuffers(); + } finally { + closed = true; + } } /** @@ -227,7 +232,7 @@ public class CryptoOutputStream extends FilterOutputStream implements * underlying stream, then do the flush. */ @Override - public void flush() throws IOException { + public synchronized void flush() throws IOException { checkStream(); encrypt(); super.flush();