spring-cloud / spring-cloud/spring-cloud-stream

Error serializing Avro response message when using the Test Binder

Open
#3,146 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
1.1k
Forks
646
Avg merge
2d 3h
Merged PRs (30d)
8

Description

Describe the issue
Im trying to use Spring Cloud Stream test binder to speed up my integration tests (I'm currently using Testcontainers and everything is working fine, but the startup time is slow). However, when using the test binder there is a weird behavior when serializing the output message, because even if it's well generated and everything seems to work well, the byte array with the payload only contains part of the message. I provide you a link to my GitHub repository with the sample code to reproduce the issue.

It seems that, when building the byte array from the response message, for a reason I'm not able to find the outgoing byte array misses data, because the incoming payload is correct but the written bytes don't match it.

Can you help me in solving this issue, or point me in the right direction to fix it? As soon as you provide me clues about where is the root cause, I'm happy to contribute with the fix to it if needed, but for now I only was able to find where the problem comes from, but not how can I fix it.

Thank you very much for your time!

To Reproduce
Steps to reproduce the behavior:

  1. If you run GreeterTestcontainersTest class, the test will work well
  2. If you run GreeterTestbindersTest, you will currently see an error because of a bad header when decoding the response. As you can see in the logs, the received payload only contains the value inside message field on the response object with an unknown prefix byte instead of the complete response object, causing the decoding error.

Version of the framework
4.3.0
Expected behavior
When receiving the response payload as a byte array, I should be able to build my output object by using
Screenshots

Additional context
GitHub repository with code sample to reproduce the issue: https://github.com/tamamico/poc-spring-cloud-stream-native.git

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by cloning the linked reproduction repository and running GreeterTestcontainersTest and GreeterTestbindersTest to compare their behavior. Trace the Test Binder's Avro response serialization and decoding path, using the logs to identify why the byte array is truncated or prefixed incorrectly. Done means GreeterTestbindersTest decodes the complete response payload without the bad-header error.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend, distributed-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.