I use bytebuddy-agent to add a dynamic field for Jedis class, and in JedisCluster constructor, there will be three Jedis instance created which will cause JVM loading Jedis class. What make me confused is that
when I put code Jedis jedis = new Jedis("localhost", 6379)
in front of code JedisCluster cluster = new JedisCluster(nodes)
, bytebuddy-agent add dynamic field to Jedis class successfully as follow.
@Test
public void testOnConstruct() throws Exception {
Jedis jedis = new Jedis("localhost", 6379);
Set<HostAndPort> nodes = new HashSet<>(3);
nodes.add(new HostAndPort("192.168.146.128", 7001));
nodes.add(new HostAndPort("192.168.146.128", 7002));
nodes.add(new HostAndPort("192.168.146.128", 7003));
JedisCluster cluster = new JedisCluster(nodes);
}
If I put Jedis jedis = new Jedis("localhost", 6379)
after JedisCluster cluster = new JedisCluster(nodes)
, bytebuddy-agent can't add dynamic field to Jedis class successfully.
I need you help, thanks.