Repository: hadoop Updated Branches: refs/heads/trunk ffc75d6eb -> 3472e3bd6
HADOOP-11494. Lock acquisition on WrappedInputStream#unwrappedRpcBuffer may race with another thread. Contributed by Ted Yu. Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/3472e3bd Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/3472e3bd Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/3472e3bd Branch: refs/heads/trunk Commit: 3472e3bd6c50558870b86c9ccfea5072385fa991 Parents: ffc75d6 Author: Benoy Antony <[email protected]> Authored: Mon Feb 2 10:34:47 2015 -0800 Committer: Benoy Antony <[email protected]> Committed: Mon Feb 2 10:34:47 2015 -0800 ---------------------------------------------------------------------- .../org/apache/hadoop/security/SaslRpcClient.java | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hadoop/blob/3472e3bd/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/SaslRpcClient.java ---------------------------------------------------------------------- diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/SaslRpcClient.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/SaslRpcClient.java index dfb0898..4a1a397 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/SaslRpcClient.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/SaslRpcClient.java @@ -573,17 +573,15 @@ public class SaslRpcClient { } @Override - public int read(byte[] buf, int off, int len) throws IOException { - synchronized(unwrappedRpcBuffer) { - // fill the buffer with the next RPC message - if (unwrappedRpcBuffer.remaining() == 0) { - readNextRpcPacket(); - } - // satisfy as much of the request as possible - int readLen = Math.min(len, unwrappedRpcBuffer.remaining()); - unwrappedRpcBuffer.get(buf, off, readLen); - return readLen; + public synchronized int read(byte[] buf, int off, int len) throws IOException { + // fill the buffer with the next RPC message + if (unwrappedRpcBuffer.remaining() == 0) { + readNextRpcPacket(); } + // 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
