zD12 / pircbotx

Automatically exported from code.google.com/p/pircbotx
0 stars 0 forks source link

WHOISEvent Returns NPE when nick does not exist #191

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Trigger WHOISevent on an offline nick
2.
3.

What is the expected output? What do you see instead?
I expect it to either return null or return empty, or even throw an Exception  
I can catch. Instead I get this:

[2014/07/29 15:46:09] [botPool0-bot0] [INFO] org.pircbotx.InputParser - 
:morgan.freenode.net 401 WaveTactDev egwgqew :No such nick/channel
[2014/07/29 15:46:09] [botPool0-bot0] [INFO] org.pircbotx.InputParser - 
:morgan.freenode.net 318 WaveTactDev egwgqew :End of /WHOIS list.
[2014/07/29 15:46:09] [botPool0-bot0] [ERROR] org.pircbotx.PircBotX - Exception 
encountered when parsing line
java.lang.NullPointerException
    at org.pircbotx.InputParser.processServerResponse(InputParser.java:776)
    at org.pircbotx.InputParser.handleLine(InputParser.java:326)
    at org.pircbotx.PircBotX.startLineProcessing(PircBotX.java:283)
    at org.pircbotx.PircBotX.connect(PircBotX.java:244)
    at org.pircbotx.MultiBotManager$BotRunner.call(MultiBotManager.java:219)
    at org.pircbotx.MultiBotManager$BotRunner.call(MultiBotManager.java:212)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

What version of the product are you using? On what operating system?

PircBotX-2.1SNAPshot

Please provide any additional information below.

Original issue reported on code.google.com by jzhou2...@gmail.com on 29 Jul 2014 at 8:04

GoogleCodeExporter commented 9 years ago
This is a test patch to test 
https://groups.google.com/d/msg/pircbotx/iTkdcdAHUEI/O6UyIKyZMioJ

Original comment by Lord.Qua...@gmail.com on 6 Aug 2014 at 1:52

Attachments:

GoogleCodeExporter commented 9 years ago
Due to the design of PircBotX this is a fairly complex issue. The fix in 
Revision 170d103136f9 is temporary until I can re-structure InputParser in 2.2. 
I'm copying my explanation from 
Configuration.Builder.setWhoisFailedTrackingEnabled() :

When a WHOIS request fails, the servers sends back a generic 401 
(ERR_NOSUCHNICK) and 318 (RPL_ENDOFWHOIS). However 401 is also used for failed 
PMs and other commands that are targeted to a nick. PircBotX's current design 
is unable to link a sent command and it's response, so upon encountering a 401 
it doesn't know if it's a failed WHOIS, a failed PM, or something else

The temporary fix is to track all 401's as potential failed WHOIS requests and 
remove any that have a 318 following. But now there's a memory leak if there 
are any 401's that aren't failed WHOIS requests. Most bots should not be 
affected but for convenience this workaround can be disabled.

By default this is enabled

Original comment by Lord.Qua...@gmail.com on 8 Aug 2014 at 2:37