FrankChen021 commented on PR #13286:
URL: https://github.com/apache/druid/pull/13286#issuecomment-1299470197

   > > 
   > 
   > I realized that there are two conditions that may lead to `NPE` in the 
access identifier
   > 
   > 1. The `identifier` may be modified by the `emitMetric` thread. Since 
identifier is a common object attribute, it may not be visible to the 
`PrometheusPushGatewayEmitter` thread
   > 2. `emitMetric` is not called in advance, but the identifier is accessed.
   
   Yeah, the 2nd case is the reason. 
   The check logic in `pushMetric` and `flush` is a little bit chaos. Could you 
improve it by putting all checks together like:
   
   ```java
     private void pushMetric()
     {
       if ( pushGateway == null || identifier == null) {
          return ;
      }
     ...
   ```
   
   Another point(not relevant to this PR) is, checking if namespace is null is 
meaningless since it's guaranteed it won't be null.
   
   ```java
     @JsonCreator
     public PrometheusEmitterConfig(
         ...
     )
     {
       ...
       this.namespace = namespace != null ? namespace : "druid";
   ```


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