CCCLL opened a new issue, #16530:
URL: https://github.com/apache/dubbo/issues/16530

   ### Apache Dubbo Component
   
   Java SDK (apache/dubbo)
   
   ### Dubbo Version
   
   `3.3` branch (cb05763298), OpenJDK 21, macOS. The argument parsing goes back 
to `CountTelnetHandler` in 2.0.7 and was carried over to the QoS `CountTelnet` 
in #8175.
   
   ### Steps to reproduce this issue
   
   1. Start a provider with QoS enabled and a dubbo service (here `repro.Echo` 
with a method `length`).
   2. Connect to the QoS port and run `cd repro.Echo`, then `count length 3`.
   
   The statistics table is printed once. Without `cd`, `count repro.Echo length 
3` prints it three times, one second apart.
   
   `CountTelnet#execute` reads the times like this:
   
   ```java
   if (service == null || service.length() == 0) {
       service = args[0];
       method = args.length > 1 ? args[1] : null;
   } else {
       method = args.length > 0 ? args[0] : null;
   }
   if (StringUtils.isNumber(method)) {
       times = method;
       method = null;
   } else {
       times = args.length > 2 ? args[2] : "1";
   }
   ```
   
   After `cd`, the arguments are `[method, times]`, so `args[2]` does not exist 
and `times` falls back to `"1"`. (`count length 3 5` after `cd` runs five 
times.)
   
   ### What you expected to happen
   
   `count length 3` after `cd repro.Echo` prints the table three times, like 
`count repro.Echo length 3`. The usage message of the command also describes 
`cd XxxService` as an alternative to giving the service name (`count XxxService 
xxxMethod 10 ... or "cd XxxService" firstly`).
   
   ### Anything else
   
   `count 3` after `cd` (no method) already works, because a numeric first 
argument is taken as the times.
   
   ### Are you willing to submit a pull request to fix on your own?
   
   - [x] Yes I am willing to submit a pull request on my own!
   


-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to