Recover panics in irc.Client.recv()

This commit is contained in:
Ken-Håvard Lieng 2016-01-13 19:06:55 +01:00
parent f429a528ba
commit cbbfda3e36
2 changed files with 17 additions and 0 deletions

View File

@ -146,6 +146,10 @@ func (c *Client) send() {
} }
func (c *Client) recv() { func (c *Client) recv() {
defer func() {
recover()
}()
c.sendRecv.Add(1) c.sendRecv.Add(1)
defer c.sendRecv.Done() defer c.sendRecv.Done()

View File

@ -132,6 +132,19 @@ func TestRecv(t *testing.T) {
initTestClient() initTestClient()
} }
func TestRecvRecoversPanic(t *testing.T) {
defer func() {
assert.Nil(t, recover())
}()
buf := bytes.NewBuffer([]byte("CMD\r\n"))
c.reader = bufio.NewReader(buf)
close(c.Messages)
c.recv()
c.Messages = make(chan *Message, 32)
}
/*func TestRecvTriggersReconnect(t *testing.T) { /*func TestRecvTriggersReconnect(t *testing.T) {
c.reader = bufio.NewReader(&bytes.Buffer{}) c.reader = bufio.NewReader(&bytes.Buffer{})
c.ready.Add(1) c.ready.Add(1)