MemcachedConstructorWithInetSocketAddressListArgInterceptor implements InstanceConstructorInterceptor { @Override public void onConstruct(EnhancedInstance objInst, Object[] allArguments) { StringBuilder memcachConnInfo = new StringBuilder(); @SuppressWarnings("unchecked") List<InetSocketAddress> inetSocketAddressList = (List<InetSocketAddress>) allArguments[1]; for (InetSocketAddress inetSocketAddress : inetSocketAddressList) { String host = inetSocketAddress.getAddress().getHostAddress(); int port = inetSocketAddress.getPort(); memcachConnInfo.append(host).append(":").append(port).append(";"); } if (memcachConnInfo.length() > 1) { memcachConnInfo = new StringBuilder(memcachConnInfo.substring(0, memcachConnInfo.length() - 1)); } objInst.setSkyWalkingDynamicField(memcachConnInfo.toString()); }  @Override void onConstruct(EnhancedInstance objInst, Object[] allArguments);  }
@Test public void onConstructWithInetSocketAddressList() { List<InetSocketAddress> inetSocketAddressList = new ArrayList<InetSocketAddress>(); inetSocketAddressList.add(new InetSocketAddress("127.0.0.1", 11211)); inetSocketAddressList.add(new InetSocketAddress("127.0.0.2", 11211)); interceptor.onConstruct(enhancedInstance, new Object[] { null, inetSocketAddressList }); verify(enhancedInstance).setSkyWalkingDynamicField("127.0.0.1:11211;127.0.0.2:11211"); }