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 aa...@apache.org on 2015/08/14 18:13:59 UTC
[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 <yl...@apache.org>
Authored: Fri Mar 13 02:26:16 2015 +0800
Committer: Akira Ajisaka <aa...@apache.org>
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);
* <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
@@ -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();