Skip to content

Correct DeadLetterPublishingRecoverer example to use KafkaOperations #3911

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 19, 2025

Conversation

sh-cho
Copy link
Contributor

@sh-cho sh-cho commented May 18, 2025

DeadLetterPublishingRecoverer ctor cannot take Map<Class<?>, KafkaTemplate<?, ?> as parameter, because constructor is Map<Class<?>, KafkaOperations<? extends Object, ? extends Object>>.

$ ./gradlew build
...

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':compileJava'.
> Compilation failed; see the compiler output below.
  /.../config/KafkaConfig.java:161: error: no suitable constructor found for DeadLetterPublishingRecoverer(Map<Class<?>,KafkaTemplate<?,?>>)
          return new DeadLetterPublishingRecoverer(templates);
                 ^
      constructor DeadLetterPublishingRecoverer.DeadLetterPublishingRecoverer(KafkaOperations<? extends Object,? extends Object>) is not applicable
        (argument mismatch; Map<Class<?>,KafkaTemplate<?,?>> cannot be converted to KafkaOperations<? extends Object,? extends Object>)
      constructor DeadLetterPublishingRecoverer.DeadLetterPublishingRecoverer(Map<Class<?>,KafkaOperations<? extends Object,? extends Object>>) is not applicable
        (argument mismatch; Map<Class<?>,KafkaTemplate<?,?>> cannot be converted to Map<Class<?>,KafkaOperations<? extends Object,? extends Object>>)
  Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
  1 error

* Try:
> Check your code and dependencies to fix the compilation error(s)
> Run with --scan to get full insights.

BUILD FAILED in 981ms
1 actionable task: 1 executed

I guess type should be like this Map<Class<?>, ? extends KafkaOperations<? extends Object, ? extends Object>> to get KafkaTemplate as parameter, but I'm not sure if changing signature is ok. Overloading is not possible because of type erasure.

So I only updated docs first, to upcast explicitly.

Any opinion would be helpful. Thanks

Signed-off-by: Seonghyeon Cho <seonghyeoncho96@gmail.com>
@sobychacko
Copy link
Contributor

@sh-cho Let's start with the docs on this matter as you did in the PR. Please create an issue so that we can track it. We have the opportunity to cleanup things like these in the 4.0.0 version. Let's re-evaluate it later.

@sh-cho
Copy link
Contributor Author

sh-cho commented May 19, 2025

@sobychacko Ok. I made an issue

@sobychacko sobychacko merged commit 56fa428 into spring-projects:main May 19, 2025
3 checks passed
spring-builds pushed a commit that referenced this pull request May 19, 2025
…ns` (#3911)

Signed-off-by: Seonghyeon Cho <seonghyeoncho96@gmail.com>
(cherry picked from commit 56fa428)
spring-builds pushed a commit that referenced this pull request May 19, 2025
…ns` (#3911)

Signed-off-by: Seonghyeon Cho <seonghyeoncho96@gmail.com>
(cherry picked from commit 56fa428)
@sobychacko sobychacko added this to the 4.0.0-M3 milestone May 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants