TAKETODAY opened a new issue, #131:
URL: https://github.com/apache/rocketmq-exporter/issues/131

   
   **Describe the bug**
    
   ```log
   java.lang.NullPointerException: null
        at 
org.apache.rocketmq.exporter.model.BrokerRuntimeStats.loadTps(BrokerRuntimeStats.java:149)
        at 
org.apache.rocketmq.exporter.model.BrokerRuntimeStats.<init>(BrokerRuntimeStats.java:94)
        at 
org.apache.rocketmq.exporter.task.MetricsCollectTask.collectBrokerRuntimeStats(MetricsCollectTask.java:685)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at 
org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:84)
        at 
org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)
        at 
org.springframework.scheduling.concurrent.ReschedulingRunnable.run(ReschedulingRunnable.java:93)
        at 
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at 
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
        at 
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
        at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:750)
   ```
   
   原始代码:
   
https://github.com/apache/rocketmq-exporter/blob/5fb1de22cd12555164103771aa42d93d00768ba5/src/main/java/org/apache/rocketmq/exporter/model/BrokerRuntimeStats.java#L149
   
   ```java
       private void loadTps(PutTps putTps, String value) {
           String[] arr = value.split(" ");
           if (arr.length >= 1) {
               putTps.ten = Double.parseDouble(arr[0]);
           }
           if (arr.length >= 2) {
               putTps.sixty = Double.parseDouble(arr[1]);
           }
           if (arr.length >= 3) {
               putTps.sixHundred = Double.parseDouble(arr[2]);
           }
   
       }
   ```
   
   修改后: 
   ```java
       private void loadTps(PutTps putTps, String value) {
           if (value != null) {
               String[] arr = value.split(" ");
               if (arr.length >= 1) {
                   putTps.ten = Double.parseDouble(arr[0]);
               }
               if (arr.length >= 2) {
                   putTps.sixty = Double.parseDouble(arr[1]);
               }
               if (arr.length >= 3) {
                   putTps.sixHundred = Double.parseDouble(arr[2]);
               }
           }
       }
   ```


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