You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by yl...@apache.org on 2015/03/13 04:23:42 UTC
hadoop git commit: HADOOP-11710. Make CryptoOutputStream behave like
DFSOutputStream wrt synchronization. (Sean Busbey via yliu)
Repository: hadoop
Updated Branches:
refs/heads/branch-2 32e62cb3d -> 813c93cb2
HADOOP-11710. Make CryptoOutputStream behave like DFSOutputStream wrt synchronization. (Sean Busbey via yliu)
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/813c93cb
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/813c93cb
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/813c93cb
Branch: refs/heads/branch-2
Commit: 813c93cb250d6d556604fe98845b979970bd5e18
Parents: 32e62cb
Author: yliu <yl...@apache.org>
Authored: Fri Mar 13 02:26:16 2015 +0800
Committer: yliu <yl...@apache.org>
Committed: Fri Mar 13 02:26:16 2015 +0800
----------------------------------------------------------------------
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/813c93cb/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 3317dfb..2745e18 100644
--- a/hadoop-common-project/hadoop-common/CHANGES.txt
+++ b/hadoop-common-project/hadoop-common/CHANGES.txt
@@ -683,6 +683,9 @@ Release 2.7.0 - UNRELEASED
HADOOP-11693. Azure Storage FileSystem rename operations are throttled too
aggressively to complete HBase WAL archiving. (Duo Xu via cnauroth)
+ HADOOP-11710. Make CryptoOutputStream behave like DFSOutputStream wrt
+ synchronization. (Sean Busbey via yliu)
+
Release 2.6.1 - UNRELEASED
INCOMPATIBLE CHANGES
http://git-wip-us.apache.org/repos/asf/hadoop/blob/813c93cb/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 120b378..1753019 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);
* <p/>
* 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
@@ -126,7 +129,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();
@@ -213,14 +216,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;
+ }
}
/**
@@ -228,7 +233,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();