Techcable / pircbotx

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

Missing real name (?) causes StringIndexOutOfBoundsException during processing of 352 server response #151

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I got this error during a list of 352 server responses.

I'm not totally sure, but it seems to be related to the case where no real name 
is given. In that case the output gets trimmed and consequently there is never 
a trailing space after the value for the number of hops. I guess this results 
in an index of -1 and that's of course not valid for a substring operation. 
(From quickly looking at the code, it seems that the Tokenizer at 
InputParser.java:284 automatically trims.)

I did a temporary fix myself (attached) that seems to do the trick, so it might 
be useful. 

The stack trace that gets produced:

[Thread-24] ERROR org.pircbotx.PircBotX - Exception encountered when parsing 
line 
java.lang.StringIndexOutOfBoundsException: String index out of range: -1 
   at java.lang.String.substring(String.java:1911) 
   at org.pircbotx.InputParser.processServerResponse(InputParser.java:645) 
   at org.pircbotx.InputParser.handleLine(InputParser.java:323) 
   at org.pircbotx.PircBotX.startLineProcessing(PircBotX.java:275) 
   at org.pircbotx.PircBotX.connect(PircBotX.java:236) 
   at org.pircbotx.PircBotX.startBot(PircBotX.java:151) 

Original issue reported on code.google.com by danny.va...@gmail.com on 10 Nov 2013 at 8:31

Attachments:

GoogleCodeExporter commented 9 years ago
Its surprising that I've never seen a user with a missing full name before when 
testing. Fixed in Revision e6f2fb76479b with a unit test.

Original comment by Lord.Qua...@gmail.com on 13 Nov 2013 at 8:36