You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2019/03/12 09:50:48 UTC

[GitHub] [pulsar] jiazhai opened a new issue #3806: NPE in PartitionedProducerImpl##ProducerStatsRecorderImpl

jiazhai opened a new issue #3806: NPE in PartitionedProducerImpl##ProducerStatsRecorderImpl
URL: https://github.com/apache/pulsar/issues/3806
 
 
   **Describe the bug**
   meet NPE while call PartitionedProducerImpl.getStats()
   
   **Screenshots**
   ![image](https://user-images.githubusercontent.com/6348208/54190161-4ad6b100-44ee-11e9-8044-03cdf725c177.png)
   
   **Additional context**
   
   In PartitionedProducerImpl, the stats instance(ProducerStatsRecorderImpl) is init like this.
   ```
   stats = client.getConfiguration().getStatsIntervalSeconds() > 0 ? new ProducerStatsRecorderImpl() : null;
   ```
   
   while  in ProducerStatsRecorderImpl(), all member is set to null;
   ```
   public ProducerStatsRecorderImpl() {
       numMsgsSent = null;
       numBytesSent = null;
       numSendFailed = null;
       numAcksReceived = null;
       totalMsgsSent = null;
       totalBytesSent = null;
       totalSendFailed = null;
       totalAcksReceived = null;
       ds = null;
   }
   ```
   so when call PartitionedProducerImpl.getStats(), it will meet NPE
   ```
   @Override
   public synchronized ProducerStatsRecorderImpl getStats() {
       if (stats == null) {
           return null;
       }
       stats.reset();      < === 
       for (int i = 0; i < topicMetadata.numPartitions(); i++) {
           stats.updateCumulativeStats(producers.get(i).getStats());
       }
       return stats;
   }
   
   void reset() {
       numMsgsSent.reset();   < === 
       numBytesSent.reset();
       numSendFailed.reset();
       numAcksReceived.reset();
       totalMsgsSent.reset();
       totalBytesSent.reset();
       totalSendFailed.reset();
       totalAcksReceived.reset();
   }
   
   ```

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services