diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/ServerCall.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/ServerCall.java index a5c8a3920b1..b53c770cf37 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/ServerCall.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/ServerCall.java @@ -281,9 +281,6 @@ public abstract class ServerCall implements RpcCa } } bc = new BufferChain(responseBufs); - if (connection.useWrap) { - bc = wrapWithSasl(bc); - } } catch (IOException e) { RpcServer.LOG.warn("Exception while creating response " + e); } @@ -547,6 +544,20 @@ public abstract class ServerCall implements RpcCa @Override public synchronized BufferChain getResponse() { - return response; + if (connection.useWrap) { + /* + * wrapping result with SASL as the last step just before sending it out, so + * every message must have the right increasing sequence number + */ + try { + return wrapWithSasl(response); + } catch (IOException e) { + /* it is exactly the same what setResponse() does */ + RpcServer.LOG.warn("Exception while creating response " + e); + return null; + } + } else { + return response; + } } }