Skip to content

Commit

Permalink
Merge pull request twitter#406 from tom-dalton-fanduel/bugfix/redis-e…
Browse files Browse the repository at this point in the history
…rror-response-parser

Fix parsing bug when error body contains no spaces
  • Loading branch information
manjuraj committed Oct 1, 2015
2 parents 0e8708b + 6f32a92 commit 34f369f
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/proto/nc_redis.c
Original file line number Diff line number Diff line change
Expand Up @@ -1920,6 +1920,9 @@ redis_parse_rsp(struct msg *r)

break;
}
if (ch == CR) {
p -= 1;
}
state = SW_RUNTO_CRLF;
}

Expand Down
33 changes: 33 additions & 0 deletions tests/test_redis/test_lua_error_return.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env python
#coding: utf-8

from unittest import TestCase

from redis import Redis, ResponseError

from common import *


class LuaReturnErrorTestCase(TestCase):

def test_lua_return_error(self):
"""Test the error described on issue 404 is fixed.
https://github.com/twitter/twemproxy/issues/404
"""
r = getconn()
p = r.pipeline(transaction=False)

p.set("test_key", "bananas!")
p.eval('return {err="dummyerror"}', 1, "dummy_key")
p.get("test_key")

set_result, eval_result, get_result = p.execute(raise_on_error=False)

self.assertTrue(set_result)

self.assertIsInstance(eval_result, ResponseError)
self.assertEqual(eval_result.message, "dummyerror")

self.assertEqual(get_result, "bananas!")

0 comments on commit 34f369f

Please sign in to comment.