beautyarbutin opened a new issue, #11246:
URL: https://github.com/apache/rocketmq/issues/11246

   ### Runtime platform environment
   
   Windows 11 (10.0.26200). Reproduced in the `remoting` module without 
starting a broker or connecting to a NameServer.
   
   ### RocketMQ version
   
   `develop` at `78b96bc5e21216cd7896efae08f90c5cde4cae53` (5.5.1-SNAPSHOT 
project version).
   
   ### JDK Version
   
   Eclipse Temurin OpenJDK 8u504.
   
   ### Describe the Bug
   
   `NettyRemotingClient.updateNameServerAddressList(List<String>)` shuffles the 
caller's list in place and stores that same list as `namesrvAddrList`. A 
read-only list with two or more addresses causes 
`UnsupportedOperationException`. If a caller later changes a mutable list it 
passed in, the client's NameServer addresses change without another update 
call. For example, clearing the input leaves the client with an empty address 
list.
   
   This is a defect for callers that use the public `RemotingClient` API with a 
read-only or reused list. The built-in string-based wrappers generally create 
fresh mutable lists, so this report does not claim that the default wrappers 
fail.
   
   ### Steps to Reproduce
   
   ```java
   NettyRemotingClient client = new NettyRemotingClient(new 
NettyClientConfig());
   List<String> addresses = new ArrayList<>(Arrays.asList("127.0.0.1:9876", 
"127.0.0.2:9876"));
   client.updateNameServerAddressList(addresses);
   addresses.clear();
   System.out.println(client.getNameServerAddressList()); // []
   client.shutdown();
   ```
   
   Alternatively, pass 
`Collections.unmodifiableList(Arrays.asList("127.0.0.1:9876", 
"127.0.0.2:9876"))`; the update throws `UnsupportedOperationException` during 
`Collections.shuffle`.
   
   ### What Did You Expect to See?
   
   The client retains its own snapshot of the provided NameServer addresses, 
and accepts a read-only input list.
   
   ### What Did You See Instead?
   
   The client's address list follows later mutations of the input list, and a 
read-only input list is rejected.
   
   ### Additional Context
   
   The mutable-input scenario was reproduced with a failing 
`NettyRemotingClientTest` before the fix. A minimal defensive copy in the 
update method makes both regression tests pass; the complete test class passes 
18/18 tests with zero Checkstyle violations.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to