HADOOP-11710. Make CryptoOutputStream behave like DFSOutputStream wrt synchronization. (Sean Busbey via yliu)
(cherry picked from commit 813c93cb25
)
This commit is contained in:
parent
9642a861e1
commit
2230754f2a
|
@ -48,6 +48,9 @@ Release 2.6.1 - UNRELEASED
|
||||||
HADOOP-11674. oneByteBuf in CryptoInputStream and CryptoOutputStream
|
HADOOP-11674. oneByteBuf in CryptoInputStream and CryptoOutputStream
|
||||||
should be non static. (Sean Busbey via yliu)
|
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
|
Release 2.6.0 - 2014-11-18
|
||||||
|
|
||||||
INCOMPATIBLE CHANGES
|
INCOMPATIBLE CHANGES
|
||||||
|
|
|
@ -40,6 +40,9 @@ import com.google.common.base.Preconditions;
|
||||||
* padding = pos%(algorithm blocksize);
|
* padding = pos%(algorithm blocksize);
|
||||||
* <p/>
|
* <p/>
|
||||||
* The underlying stream offset is maintained as state.
|
* 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
|
@InterfaceAudience.Private
|
||||||
@InterfaceStability.Evolving
|
@InterfaceStability.Evolving
|
||||||
|
@ -125,7 +128,7 @@ public class CryptoOutputStream extends FilterOutputStream implements
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
@Override
|
@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();
|
checkStream();
|
||||||
if (b == null) {
|
if (b == null) {
|
||||||
throw new NullPointerException();
|
throw new NullPointerException();
|
||||||
|
@ -212,14 +215,16 @@ public class CryptoOutputStream extends FilterOutputStream implements
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void close() throws IOException {
|
public synchronized void close() throws IOException {
|
||||||
if (closed) {
|
if (closed) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
super.close();
|
super.close();
|
||||||
freeBuffers();
|
freeBuffers();
|
||||||
closed = true;
|
} finally {
|
||||||
|
closed = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -227,7 +232,7 @@ public class CryptoOutputStream extends FilterOutputStream implements
|
||||||
* underlying stream, then do the flush.
|
* underlying stream, then do the flush.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void flush() throws IOException {
|
public synchronized void flush() throws IOException {
|
||||||
checkStream();
|
checkStream();
|
||||||
encrypt();
|
encrypt();
|
||||||
super.flush();
|
super.flush();
|
||||||
|
|
Loading…
Reference in New Issue