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

This commit is contained in:
Wang Yuxuan 2019-11-11 13:18:38 +08:00 committed by Ayush Saxena
parent 6663d6a5c2
commit b25a37c322
2 changed files with 11 additions and 1 deletions

View File

@ -374,7 +374,7 @@ protected static <T> ConnectionContext newConnection(Configuration conf,
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);
}

View File

@ -23,6 +23,7 @@
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 void testConfigureConnectionActiveRatio() throws IOException {
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));
}
}