瀏覽代碼

HDFS-14962. RBF: ConnectionPool#newConnection() error log wrong protocol class (#1699). Contributed by Yuxuan Wang.

Wang Yuxuan 5 年之前
父節點
當前提交
b25a37c322

+ 1 - 1
hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/ConnectionPool.java

@@ -374,7 +374,7 @@ public class ConnectionPool {
       throws IOException {
     if (!PROTO_MAP.containsKey(proto)) {
       String msg = "Unsupported protocol for connection to NameNode: "
-          + ((proto != null) ? proto.getClass().getName() : "null");
+          + ((proto != null) ? proto.getName() : "null");
       LOG.error(msg);
       throw new IllegalStateException(msg);
     }

+ 10 - 0
hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/router/TestConnectionManager.java

@@ -23,6 +23,7 @@ import org.apache.hadoop.hdfs.server.protocol.NamenodeProtocol;
 import org.apache.hadoop.net.NetUtils;
 import org.apache.hadoop.security.UserGroupInformation;
 import org.apache.hadoop.test.GenericTestUtils;
+import org.apache.hadoop.test.LambdaTestUtils;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -301,4 +302,13 @@ public class TestConnectionManager {
 
     tmpConnManager.close();
   }
+
+  @Test
+  public void testUnsupportedProtoExceptionMsg() throws Exception {
+    LambdaTestUtils.intercept(IllegalStateException.class,
+        "Unsupported protocol for connection to NameNode: "
+            + TestConnectionManager.class.getName(),
+        () -> ConnectionPool.newConnection(conf, TEST_NN_ADDRESS, TEST_USER1,
+            TestConnectionManager.class));
+  }
 }