Thanks to visit codestin.com
Credit goes to github.com

Skip to content

KafkaProducer.send does not raise NameError in custom serializer #1462

Closed
@Po-Hsun-Su

Description

@Po-Hsun-Su

The KafkaProducer.send function has a try/except clause that hides the exception in a custom serializer. This makes finding bugs inside custom serializer difficult.
Example code:

from kafka import KafkaProducer

def raiseError():
    raise NameError

producer = KafkaProducer(bootstrap_servers="localhost:9092",
                 value_serializer=lambda m: raiseError(m))
producer.send("topic", "value", "key")

This program will not raise error even though it should. Adding except NameError: in KafkaProducer.send can solve this no raise issue, but I am not sure if this is a good idea.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions