HADOOP-11494. Lock acquisition on WrappedInputStream#unwrappedRpcBuffer may race with another thread. Contributed by Ted Yu.
This commit is contained in:
parent
ffc75d6ebe
commit
3472e3bd6c
|
@ -573,17 +573,15 @@ 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();
|
|
||||||
}
|
|
||||||
// satisfy as much of the request as possible
|
|
||||||
int readLen = Math.min(len, unwrappedRpcBuffer.remaining());
|
|
||||||
unwrappedRpcBuffer.get(buf, off, readLen);
|
|
||||||
return readLen;
|
|
||||||
}
|
}
|
||||||
|
// satisfy as much of the request as possible
|
||||||
|
int readLen = Math.min(len, unwrappedRpcBuffer.remaining());
|
||||||
|
unwrappedRpcBuffer.get(buf, off, 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
|
||||||
|
|
Loading…
Reference in New Issue