From 54e622bae9acf6d87e770f08b5bd0d72d6c1b171 Mon Sep 17 00:00:00 2001 From: Balazs Meszaros Date: Thu, 18 Feb 2021 11:24:46 +0100 Subject: [PATCH] HBASE-25586 Fix HBASE-22492 on branch-2 (SASL GapToken) ServerCall.java: calling wrapWithSasl() was moved to getResponse(), so the SASL wrapping is delayed until the reply is sent back to the client. --- .../apache/hadoop/hbase/ipc/ServerCall.java | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) 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 a5c8a3920b17..b53c770cf37b 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 synchronized void setResponse(Message m, final CellScanner cells, Throwab } } 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 int getRemotePort() { @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; + } } }