From f26a547f2bb21ca89ffadc6375da4cb0a4a2cec0 Mon Sep 17 00:00:00 2001 From: Viraj Jasani Date: Tue, 24 Aug 2021 19:11:59 +0530 Subject: [PATCH] HADOOP-17858. Avoid possible class loading deadlock with VerifierNone initialization (#3321) (cherry picked from commit fc566ad9b0e1336381c5f6b321cdcff81768f47a) --- .../src/main/java/org/apache/hadoop/oncrpc/RpcProgram.java | 3 +-- .../main/java/org/apache/hadoop/oncrpc/security/Verifier.java | 2 -- .../java/org/apache/hadoop/oncrpc/security/VerifierNone.java | 2 ++ 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/hadoop-common-project/hadoop-nfs/src/main/java/org/apache/hadoop/oncrpc/RpcProgram.java b/hadoop-common-project/hadoop-nfs/src/main/java/org/apache/hadoop/oncrpc/RpcProgram.java index 5c059aa4550..194336ab1aa 100644 --- a/hadoop-common-project/hadoop-nfs/src/main/java/org/apache/hadoop/oncrpc/RpcProgram.java +++ b/hadoop-common-project/hadoop-nfs/src/main/java/org/apache/hadoop/oncrpc/RpcProgram.java @@ -24,7 +24,6 @@ import java.net.SocketAddress; import com.google.common.annotations.VisibleForTesting; import org.apache.hadoop.oncrpc.RpcAcceptedReply.AcceptState; -import org.apache.hadoop.oncrpc.security.Verifier; import org.apache.hadoop.oncrpc.security.VerifierNone; import org.apache.hadoop.portmap.PortmapMapping; import org.apache.hadoop.portmap.PortmapRequest; @@ -214,7 +213,7 @@ public abstract class RpcProgram extends SimpleChannelUpstreamHandler { private void sendAcceptedReply(RpcCall call, SocketAddress remoteAddress, AcceptState acceptState, ChannelHandlerContext ctx) { RpcAcceptedReply reply = RpcAcceptedReply.getInstance(call.getXid(), - acceptState, Verifier.VERIFIER_NONE); + acceptState, VerifierNone.INSTANCE); XDR out = new XDR(); reply.write(out); diff --git a/hadoop-common-project/hadoop-nfs/src/main/java/org/apache/hadoop/oncrpc/security/Verifier.java b/hadoop-common-project/hadoop-nfs/src/main/java/org/apache/hadoop/oncrpc/security/Verifier.java index 3c0e5fe36e2..585e9fb5f44 100644 --- a/hadoop-common-project/hadoop-nfs/src/main/java/org/apache/hadoop/oncrpc/security/Verifier.java +++ b/hadoop-common-project/hadoop-nfs/src/main/java/org/apache/hadoop/oncrpc/security/Verifier.java @@ -27,8 +27,6 @@ import org.apache.hadoop.oncrpc.XDR; */ public abstract class Verifier extends RpcAuthInfo { - public static final Verifier VERIFIER_NONE = new VerifierNone(); - protected Verifier(AuthFlavor flavor) { super(flavor); } diff --git a/hadoop-common-project/hadoop-nfs/src/main/java/org/apache/hadoop/oncrpc/security/VerifierNone.java b/hadoop-common-project/hadoop-nfs/src/main/java/org/apache/hadoop/oncrpc/security/VerifierNone.java index 8bccd1b9be2..90d1fda4311 100644 --- a/hadoop-common-project/hadoop-nfs/src/main/java/org/apache/hadoop/oncrpc/security/VerifierNone.java +++ b/hadoop-common-project/hadoop-nfs/src/main/java/org/apache/hadoop/oncrpc/security/VerifierNone.java @@ -24,6 +24,8 @@ import com.google.common.base.Preconditions; /** Verifier used by AUTH_NONE. */ public class VerifierNone extends Verifier { + public static final Verifier INSTANCE = new VerifierNone(); + public VerifierNone() { super(AuthFlavor.AUTH_NONE); }