ZanderXu commented on code in PR #4542:
URL: https://github.com/apache/hadoop/pull/4542#discussion_r918455307
##########
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ipc/TestRpcBase.java:
##########
@@ -154,11 +155,53 @@ protected static TestRpcService
getClient(InetSocketAddress serverAddr,
}
}
- protected static void stop(Server server, TestRpcService proxy) {
- if (proxy != null) {
- try {
- RPC.stopProxy(proxy);
- } catch (Exception ignored) {}
+ /**
+ * Try to obtain a proxy of TestRpcService with an index.
+ * @param serverAddr input server address
+ * @param clientConf input client configuration
+ * @param retryPolicy input retryPolicy
+ * @param index input index
+ * @return one proxy of TestRpcService
+ */
+ protected static TestRpcService getMultipleClientWithIndex(InetSocketAddress
serverAddr,
+ Configuration clientConf, RetryPolicy retryPolicy, int index)
+ throws ServiceException, IOException {
+ MockConnectionId connectionId = new MockConnectionId(serverAddr,
+ TestRpcService.class, UserGroupInformation.getCurrentUser(),
+ RPC.getRpcTimeout(clientConf), retryPolicy, clientConf, index);
+ return getClient(connectionId, clientConf);
+ }
+
+ /**
+ * Obtain a TestRpcService Proxy by a connectionId.
+ * @param connId input connectionId
+ * @param clientConf input configuration
+ * @return a TestRpcService Proxy
+ * @throws ServiceException a ServiceException
+ */
+ protected static TestRpcService getClient(ConnectionId connId,
+ Configuration clientConf) throws ServiceException {
+ try {
+ return RPC.getProtocolProxy(
+ TestRpcService.class,
+ 0,
+ connId,
+ clientConf,
+ NetUtils.getDefaultSocketFactory(clientConf)).getProxy();
+ } catch (IOException e) {
+ throw new ServiceException(e);
+ }
+ }
+
+ protected static void stop(Server server, TestRpcService... proxies) {
+ if (proxies != null) {
+ for (TestRpcService proxy : proxies) {
Review Comment:
It will throw NPE if `proxies` is null.
```
java.lang.NullPointerException
at org.apache.hadoop.ipc.TestRpcBase.stop(TestRpcBase.java:199)
at org.apache.hadoop.ipc.TestRPC.testServerAddress(TestRPC.java:682)
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]