HADOOP-11494. Lock acquisition on WrappedInputStream#unwrappedRpcBuffer may race with another thread. Contributed by Ted Yu.

(cherry picked from commit 3472e3bd6c)
This commit is contained in:
Benoy Antony 2015-02-02 10:34:47 -08:00
parent 648510e031
commit f3ed5b68ca
1 changed files with 8 additions and 10 deletions

View File

@ -573,8 +573,7 @@ public class SaslRpcClient {
} }
@Override @Override
public int read(byte[] buf, int off, int len) throws IOException { public synchronized int read(byte[] buf, int off, int len) throws IOException {
synchronized(unwrappedRpcBuffer) {
// fill the buffer with the next RPC message // fill the buffer with the next RPC message
if (unwrappedRpcBuffer.remaining() == 0) { if (unwrappedRpcBuffer.remaining() == 0) {
readNextRpcPacket(); readNextRpcPacket();
@ -584,7 +583,6 @@ public class SaslRpcClient {
unwrappedRpcBuffer.get(buf, off, readLen); unwrappedRpcBuffer.get(buf, off, readLen);
return readLen; return readLen;
} }
}
// all messages must be RPC SASL wrapped, else an exception is thrown // all messages must be RPC SASL wrapped, else an exception is thrown
private void readNextRpcPacket() throws IOException { private void readNextRpcPacket() throws IOException {