Author: liyin Date: Wed Jul 31 18:18:16 2013 New Revision: 1508977 URL: http://svn.apache.org/r1508977 Log: [master] Fix a potential concurrentModificationEx in HBase.ClientCache
Author: adela Summary: Replicating this fix from the swift branch Test Plan: wrote a unit test which was failing on ConcurrentModificationException with the old implementation and passing with the new one. The test adds two clients (HBaseRpc.CLIENTS.getClient(...) checks whether the client is cached - and if not it puts it in the map clients which serves as cache. The two clients are added in the map and stopClients will throw the exception, the new implementation works fine Reviewers: manukranthk, gauravm Reviewed By: manukranthk CC: hbase-eng@, aaiyer, shaneh Differential Revision: https://phabricator.fb.com/D864568 Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/ipc/HBaseRPC.java Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/ipc/HBaseRPC.java URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/ipc/HBaseRPC.java?rev=1508977&r1=1508976&r2=1508977&view=diff ============================================================================== --- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/ipc/HBaseRPC.java (original) +++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/ipc/HBaseRPC.java Wed Jul 31 18:18:16 2013 @@ -228,10 +228,11 @@ public class HBaseRPC { client.stop(); } - protected void stopClients () { + protected synchronized void stopClients() { for (Map.Entry<SocketFactory, HBaseClient> e : clients.entrySet()) { - this.stopClient (e.getValue ()); + e.getValue().stop(); } + clients.clear(); } }
