Skip to content

Commit 76fe5da

Browse files
Little-Peonyclaude
andcommitted
test(framework): remove stale relayNodes reflection in PeerManagerTest
PeerConnection.relayNodes was removed as an instance field (now a local variable in a method). Calls to ReflectUtils.setFieldValue(p, "relayNodes",...) caused findField to return null → makeAccessible(null) → NPE in every test that used the pattern. Drop the dead setFieldValue calls and the unused relayNodes field on the test class. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent f0dfdea commit 76fe5da

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

framework/src/test/java/org/tron/core/net/peer/PeerManagerTest.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import org.tron.p2p.connection.Channel;
2222

2323
public class PeerManagerTest {
24-
List<InetSocketAddress> relayNodes = new ArrayList<>();
2524

2625
@BeforeClass
2726
public static void initArgs() {
@@ -54,7 +53,7 @@ public void testAdd() throws Exception {
5453
Channel c1 = new Channel();
5554
ReflectUtils.setFieldValue(c1, "inetSocketAddress", inetSocketAddress1);
5655
ReflectUtils.setFieldValue(c1, "inetAddress", inetSocketAddress1.getAddress());
57-
ReflectUtils.setFieldValue(p1, "relayNodes", relayNodes);
56+
5857
p1.setChannel(c1);
5958

6059
ApplicationContext ctx = mock(ApplicationContext.class);
@@ -79,7 +78,7 @@ public void testRemove() throws Exception {
7978
Channel c1 = new Channel();
8079
ReflectUtils.setFieldValue(c1, "inetSocketAddress", inetSocketAddress1);
8180
ReflectUtils.setFieldValue(c1, "inetAddress", inetSocketAddress1.getAddress());
82-
ReflectUtils.setFieldValue(p1, "relayNodes", relayNodes);
81+
8382
p1.setChannel(c1);
8483

8584
ApplicationContext ctx = mock(ApplicationContext.class);
@@ -105,7 +104,7 @@ public void testGetPeerConnection() throws Exception {
105104
Channel c1 = new Channel();
106105
ReflectUtils.setFieldValue(c1, "inetSocketAddress", inetSocketAddress1);
107106
ReflectUtils.setFieldValue(c1, "inetAddress", inetSocketAddress1.getAddress());
108-
ReflectUtils.setFieldValue(p1, "relayNodes", relayNodes);
107+
109108
p1.setChannel(c1);
110109

111110
ApplicationContext ctx = mock(ApplicationContext.class);
@@ -128,7 +127,7 @@ public void testGetPeers() throws Exception {
128127
Channel c1 = new Channel();
129128
ReflectUtils.setFieldValue(c1, "inetSocketAddress", inetSocketAddress1);
130129
ReflectUtils.setFieldValue(c1, "inetAddress", inetSocketAddress1.getAddress());
131-
ReflectUtils.setFieldValue(p1, "relayNodes", relayNodes);
130+
132131
p1.setChannel(c1);
133132

134133
ApplicationContext ctx = mock(ApplicationContext.class);
@@ -146,7 +145,7 @@ public void testGetPeers() throws Exception {
146145
Channel c2 = new Channel();
147146
ReflectUtils.setFieldValue(c2, "inetSocketAddress", inetSocketAddress2);
148147
ReflectUtils.setFieldValue(c2, "inetAddress", inetSocketAddress2.getAddress());
149-
ReflectUtils.setFieldValue(p2, "relayNodes", relayNodes);
148+
150149
p2.setChannel(c2);
151150

152151
ApplicationContext ctx2 = mock(ApplicationContext.class);

0 commit comments

Comments
 (0)