HADOOP-6570. RPC#stopProxy throws NPE if getProxyEngine(proxy) returns null. Contributed by Hairong Kuang.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@911134 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Hairong Kuang 2010-02-17 18:22:40 +00:00
parent 3a7841aeb8
commit 4b4e9d741e
3 changed files with 16 additions and 2 deletions

View File

@ -207,6 +207,9 @@ Trunk (unreleased changes)
HADOOP-6549. TestDoAsEffectiveUser should use ip address of the host
for superuser ip check(jnp via boryas)
HADOOP-6570. RPC#stopProxy throws NPE if getProxyEngine(proxy) returns
null. (hairong)
Release 0.21.0 - Unreleased
INCOMPATIBLE CHANGES

View File

@ -244,8 +244,9 @@ public static Object getProxy(Class protocol, long clientVersion,
* @param proxy the proxy to be stopped
*/
public static void stopProxy(Object proxy) {
if (proxy!=null) {
getProxyEngine(proxy).stopProxy(proxy);
RpcEngine rpcEngine;
if (proxy!=null && (rpcEngine = getProxyEngine(proxy)) != null) {
rpcEngine.stopProxy(proxy);
}
}

View File

@ -39,6 +39,8 @@
import org.apache.hadoop.security.authorize.Service;
import org.apache.hadoop.security.authorize.ServiceAuthorizationManager;
import static org.mockito.Mockito.*;
/** Unit tests for RPC. */
public class TestRPC extends TestCase {
private static final String ADDRESS = "0.0.0.0";
@ -392,6 +394,14 @@ public void testNoPings() throws Exception {
conf.setBoolean("ipc.client.ping", false);
new TestRPC("testnoPings").testCalls(conf);
}
/**
* Test stopping a non-registered proxy
* @throws Exception
*/
public void testStopNonRegisteredProxy() throws Exception {
RPC.stopProxy(mock(TestProtocol.class));
}
public static void main(String[] args) throws Exception {