Skip to content
This repository has been archived by the owner on Mar 24, 2021. It is now read-only.

Commit

Permalink
fix exception when messageset is too large for decode buffer
Browse files Browse the repository at this point in the history
new exception does not inherit from ProtocolClientError, removing ambiguity about whether this error originated at the broker or the client

fixes #697
  • Loading branch information
emmettbutler committed Aug 24, 2017
1 parent 878b1ff commit 92b75f3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions pykafka/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ class NoMessagesConsumedError(KafkaException):
pass


class MessageSetDecodeFailure(KafkaException):
"""Indicates a generic failure in the decoding of a MessageSet from the broker"""
pass


class ProducerQueueFullError(KafkaException):
"""Indicates that one or more of the AsyncProducer's internal queues contain at least max_queued_messages messages"""
pass
Expand Down
4 changes: 2 additions & 2 deletions pykafka/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@


from .common import CompressionType, Message
from .exceptions import ERROR_CODES, MessageSizeTooLarge
from .exceptions import ERROR_CODES, MessageSetDecodeFailure
from .utils import Serializable, compression, struct_helpers
from .utils.compat import iteritems, itervalues, buffer

Expand Down Expand Up @@ -379,7 +379,7 @@ def decode(cls, buff, partition_id=-1):
messages.append(message)
offset += size
if len(messages) == 0 and attempted:
raise MessageSizeTooLarge(size)
raise MessageSetDecodeFailure(size)
return MessageSet(messages=messages)

def pack_into(self, buff, offset):
Expand Down

0 comments on commit 92b75f3

Please sign in to comment.