Skip to content

TopicResolver uses map<CLass<*>, topicname>. Failure with spring-devtools #1078

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

Closed
fkurth opened this issue Apr 4, 2025 · 2 comments · Fixed by #1091
Closed

TopicResolver uses map<CLass<*>, topicname>. Failure with spring-devtools #1078

fkurth opened this issue Apr 4, 2025 · 2 comments · Fixed by #1091
Labels
type: improvement An improvement of implementation of existing feature

Comments

@fkurth
Copy link

fkurth commented Apr 4, 2025

The DefaultTopicResolver uses a Map with Class<*> as key.

This fails if the project uses multiple classloaders, because Class<> has no equal implementation, every classloader creates a different "version" of the class.

For example, register custom mappings and add spring-devtools to the project.
This brings in a "RestartableClassLoader".
Other instrumentations might lead to similar problems.

The TopicResolver will fail for the custom mappings.

https://docs.spring.io/spring-boot/reference/using/devtools.html#using.devtools.restart.disable
https://stackoverflow.com/questions/2625546/is-using-the-class-instance-as-a-map-key-a-best-practice

Version 1.2.4

@onobc
Copy link
Collaborator

onobc commented Apr 6, 2025

Hi @fkurth , thanks for the report. We will take a look.

@onobc onobc added the status: waiting-for-triage An issue we've not yet triaged label Apr 6, 2025
onobc added a commit to onobc/spring-pulsar that referenced this issue Apr 18, 2025
This commit updates the DefaultTopicResolver and DefaulSchemaResolver to use
String class names rather than Class instances as map keys for their custom
mappings.

Resolves spring-projects#1078
onobc added a commit to onobc/spring-pulsar that referenced this issue Apr 21, 2025
This commit updates the DefaultTopicResolver and DefaulSchemaResolver to use
String class names rather than Class instances as map keys for their custom
mappings.

Resolves spring-projects#1078
@onobc
Copy link
Collaborator

onobc commented Apr 21, 2025

Hi @fkurth ,
I have made the changes to use string classname as key rather than the class instance. However, I am unable to reproduce the failure using devtools and custom mappings. Can you provide the exception (failure) you were seeing and sample code you are using (how are you adding the custom mappings)?

Thanks

onobc added a commit to onobc/spring-pulsar that referenced this issue Apr 21, 2025
This commit updates the DefaultTopicResolver and DefaulSchemaResolver to use
String class names rather than Class instances as map keys for their custom
mappings.

Resolves spring-projects#1078
onobc added a commit to onobc/spring-pulsar that referenced this issue Apr 21, 2025
This commit updates the DefaultTopicResolver and DefaulSchemaResolver to use
String class names rather than Class instances as map keys for their custom
mappings.

Resolves spring-projects#1078
@onobc onobc added type: feature A new feature or enhacement type: improvement An improvement of implementation of existing feature and removed type: feature A new feature or enhacement status: waiting-for-triage An issue we've not yet triaged labels Apr 21, 2025
@onobc onobc closed this as completed in 605bcde Apr 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: improvement An improvement of implementation of existing feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants