-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Null Pointer Exception in NSQConsumer #10
base: master
Are you sure you want to change the base?
Conversation
Fixed potential NPE thrown in AbstractConsumer + some code improvements
I will try to find some time in the next few months/weeks to add more tests and improve code. The library works really well otherwise 👍 |
@dustismo any thoughts? |
protected static Logger log = LoggerFactory.getLogger(AbstractNSQClient.class); | ||
|
||
|
||
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractNSQClient.class); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why change this? I'm not against the change (log vs LOGGER) but you'll need to update it in the other classes for consistency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I happened to have modified these files when I was investigating the issue. I'd like to do the refactoring across all files but wanted to keep this fix rather small.
@kenshiro-o sorry it took so long for a response. I made a couple of comments otherwise looks good, thanks! |
@dustismo I have removed the model package. With regards to changing the scope and name of the Logger across all source files, I'd rather do this in a separate PR to better contain the change. Also the main reason why I modified your Logger instances is because they should be immutable (final) and also only relevant to the current class. You don't need to use protected as your subclasses define their own logger and hence do not inherit their parent's logger. Lastly the name was capitalized by convention since your Logger is a constant now. Let me know if you are OK with the current PR 👍 |
@kenshiro-o Looks good to me. Looks like there is some conflict with master, so if you fix that I will merge. |
@dustismo I have finally found the time to merge the Cheers, |
@kenshiro-o hi Ed 😄 I've taken over maintenance of this repo - what do we need to do here to get this in? |
Hey @mreiferson 😸 I had completely forgotten about this PR... |
The code in the NSQConsumer.java does not check for a null Connection being returned from the call to
This PR fixes this issue which is manifested when we try to call a method on a null Connection (e.g. https://github.com/dustismo/TrendrrNSQClient/blob/master/src/main/java/com/trendrr/nsq/NSQConsumer.java#L39).
Moreover, some refactoring was done and tests added. In case you are interested, the stack trace looked as follows: