Techcable / pircbotx

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

Attempting to send a message through sendIRC() while the bot is disconnected RuntimeException #226

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Have the bot disconnect from the server somehow. Don't check for 
.isConnected() (put test code onDisconnect for example).
2. Sttempt to send a message without an event method (through 
.getBot().sendIRC().message().
3. Fatal crash RuntimeException. Kills the current thread.
I think failing to send a message to a server because we're disconnected should 
be a recoverable exception.

This happened during execution:
Exception in thread "SaveData" java.lang.RuntimeException: Not connected to 
server
    at org.pircbotx.output.OutputRaw.rawLine(OutputRaw.java:64)
    at org.pircbotx.output.OutputRaw.rawLineSplit(OutputRaw.java:139)
    at org.pircbotx.output.OutputRaw.rawLineSplit(OutputRaw.java:126)
    at org.pircbotx.output.OutputIRC.message(OutputIRC.java:138)
    at com.nesbot.readwrite.SaveData$SaveDataTimer.run(SaveData.java:66)
    at java.util.TimerThread.mainLoop(Timer.java:555)
    at java.util.TimerThread.run(Timer.java:505)

Reproduced with onDisconnect:
java.lang.RuntimeException: Not connected to server
    at org.pircbotx.output.OutputRaw.rawLine(OutputRaw.java:64) ~[pircbotx-2.1-20150105.090543-100.jar:?]
    at org.pircbotx.output.OutputRaw.rawLineSplit(OutputRaw.java:139) ~[pircbotx-2.1-20150105.090543-100.jar:?]
    at org.pircbotx.output.OutputRaw.rawLineSplit(OutputRaw.java:126) ~[pircbotx-2.1-20150105.090543-100.jar:?]
    at org.pircbotx.output.OutputIRC.message(OutputIRC.java:138) ~[pircbotx-2.1-20150105.090543-100.jar:?]
    at com.nesbot.NesBot.onDisconnect(NesBot.java:93) ~[classes/:?]

If I try to use 
.getBot().getUserChannelDao().getChannel("#testbotbot").send().message()
I only get a DaoException. It might crash nicer but I can't reproduce.

What version of the product are you using? On what operating system?
Latest snapsnot. Ubuntu / Windows.

Original issue reported on code.google.com by Tnade...@gmail.com on 8 Jan 2015 at 12:17

GoogleCodeExporter commented 9 years ago
How do you expect pircbotx to recover from this? No connection means no 
messages can be sent, still trying to send a message would logically cause an 
error. 

The Daoexception comes from the bot shutting down and clearing internal state. 

Original comment by Lord.Qua...@gmail.com on 8 Jan 2015 at 2:40

GoogleCodeExporter commented 9 years ago
You can close this. I misunderstood what happened following the error. My bot 
froze up waiting for SaveData to complete before restart.

Original comment by Tnade...@gmail.com on 8 Jan 2015 at 3:10

GoogleCodeExporter commented 9 years ago
Understand

Original comment by Lord.Qua...@gmail.com on 8 Jan 2015 at 3:26