Github user srdo commented on a diff in the pull request:

    https://github.com/apache/storm/pull/2367#discussion_r144069466
  
    --- Diff: 
external/storm-kafka-client/src/main/java/org/apache/storm/kafka/spout/internal/OffsetManager.java
 ---
    @@ -53,8 +54,8 @@
         public OffsetManager(TopicPartition tp, long initialFetchOffset) {
             this.tp = tp;
             this.initialFetchOffset = initialFetchOffset;
    -        this.committedOffset = initialFetchOffset - 1;
    -        LOG.debug("Instantiated {}", this);
    +        this.committedOffset = initialFetchOffset;
    +        LOG.debug("Instantiated {}", this.toString());
    --- End diff --
    
    The warning I get is just "leaking this in constructor", Netbeans has the 
following description: "Using this as parameter can be dangerous in the 
contructor because the object is not fully initialized.". IntelliJ and Eclipse 
have similar warnings I believe. 
    
    It's basically saying not to use `this` as a parameter from the 
constructor, because the called method may use fields that aren't initialized. 
I agree that leaking `this` from the constructor is not dangerous here, because 
sfl4j just calls toString, but I'd still like to get rid of the warning. The 
reason this is flagged is because `this` is used as a parameter to LOG.debug, 
and not as part of a string concatenation. The IDE can't tell whether `this` is 
used unsafely in LOG.debug, so it's flagged as a warning.


---

Reply via email to