Skip to content

ByteEncoder vs. StringEncoder problems #1625

Closed
@glagnar

Description

@glagnar
Versions

Please specify real version numbers or git SHAs, not just "Latest" since that changes fairly regularly.

Sarama Kafka Go
v1.26.1 2.4 1.13.4
Configuration

What configuration values are you using for Sarama and Kafka?

	config.Producer.Return.Successes = false
	config.Producer.Return.Errors = true
	config.Producer.Retry.Max = 5
Problem Description

I am sending binary messages to kafka, that have this format:
[60 0 34 147 249 175 183 0 0 3 174 0 0 7 209 94 77 83 104 0 0 1 248 0 0 0 0 0 0 0 0 1 253 62]
( They start with < and end with > )

When I use the byte encoder, messages are 'mixed up' i.e. if I consume the stream of data back from Kafka things work fine, but the individual messages are broken in seemingly random places.

If I use the StringEncoder, I get the expected behaviour where each kafka message is complete. Is this an error ?

Activity

cheesedosa

cheesedosa commented on Mar 13, 2020

@cheesedosa

Sounds like an ownership issue. Are you reusing the []byte after you call send? The ByteEncoder does not make a copy. strings in golang are always copies.

ghost

ghost commented on Mar 17, 2021

@ghost

Thank you for taking the time to raise this issue. However, it has not had any activity on it in the past 90 days and will be closed in 30 days if no updates occur.
Please check if the master branch has already resolved the issue since it was raised. If you believe the issue is still valid and you would like input from the maintainers then please comment to ask for it to be reviewed.

ghost added
staleIssues and pull requests without any recent activity
on Mar 17, 2021
dnwe

dnwe commented on Aug 24, 2023

@dnwe
Collaborator

Closing as believed to have been fixed. Issue due to []byte re-use

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    staleIssues and pull requests without any recent activity

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @glagnar@dnwe@cheesedosa

        Issue actions

          ByteEncoder vs. StringEncoder problems · Issue #1625 · IBM/sarama