Skip to content
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

missing _class causes failure when deserializing to ObjectRecord #2251

Closed
lrozek opened this issue Jan 28, 2022 · 9 comments
Closed

missing _class causes failure when deserializing to ObjectRecord #2251

lrozek opened this issue Jan 28, 2022 · 9 comments
Assignees
Labels
status: duplicate A duplicate of another issue

Comments

@lrozek
Copy link

lrozek commented Jan 28, 2022

StreamMessageListenerContainerOptions#targetType
https://github.com/lrozek/redis-stream-deserialization/blob/main/redis-stream-consumer/src/main/java/pl/lrozek/redis/stream/consumer/redis/configuration/RedisListenerConfiguration.java#L29
provides information regarding what class should be used for deserialization. Producing system should not be enforced to provide _class pl.lrozek.redis.stream.consumer.domain.TemperatureReadingDto field-value pair in a stream entry, as this is an implementation detail of a consuming system.

When _class field-value pair is missing following exception is thrown:

2022-01-28 13:17:51.472 ERROR 1 --- [cTaskExecutor-1] ageListenerContainer$LoggingErrorHandler : Unexpected error occurred in scheduled task.

org.springframework.core.convert.ConversionFailedException: Failed to convert from type [org.springframework.data.redis.connection.stream.StreamRecords$ByteMapBackedRecord] to type [pl.lrozek.redis.stream.consumer.domain.TemperatureReadingDto] for value 'MapBackedRecord{recordId=1643375871467-0, kvMap={[B@1f6764b8=[B@2da89d71, [B@53d5009=[B@666e28c7}}'; nested exception is java.lang.IllegalArgumentException: Value must not be null!
	at org.springframework.data.redis.stream.StreamPollTask.convertRecord(StreamPollTask.java:198) ~[spring-data-redis-2.6.1.jar:2.6.1]
	at org.springframework.data.redis.stream.StreamPollTask.deserializeAndEmitRecords(StreamPollTask.java:176) ~[spring-data-redis-2.6.1.jar:2.6.1]
	at org.springframework.data.redis.stream.StreamPollTask.doLoop(StreamPollTask.java:148) ~[spring-data-redis-2.6.1.jar:2.6.1]
	at org.springframework.data.redis.stream.StreamPollTask.run(StreamPollTask.java:132) ~[spring-data-redis-2.6.1.jar:2.6.1]
	at java.base/java.lang.Thread.run(Unknown Source) ~[na:na]
Caused by: java.lang.IllegalArgumentException: Value must not be null!
	at org.springframework.util.Assert.notNull(Assert.java:201) ~[spring-core-5.3.15.jar:5.3.15]
	at org.springframework.data.redis.connection.stream.Record.of(Record.java:81) ~[spring-data-redis-2.6.1.jar:2.6.1]
	at org.springframework.data.redis.connection.stream.MapRecord.toObjectRecord(MapRecord.java:147) ~[spring-data-redis-2.6.1.jar:2.6.1]
	at org.springframework.data.redis.core.StreamObjectMapper.toObjectRecord(StreamObjectMapper.java:138) ~[spring-data-redis-2.6.1.jar:2.6.1]
	at org.springframework.data.redis.core.StreamOperations.map(StreamOperations.java:577) ~[spring-data-redis-2.6.1.jar:2.6.1]
	at org.springframework.data.redis.stream.DefaultStreamMessageListenerContainer.lambda$getDeserializer$2(DefaultStreamMessageListenerContainer.java:240) ~[spring-data-redis-2.6.1.jar:2.6.1]
	at org.springframework.data.redis.stream.StreamPollTask.convertRecord(StreamPollTask.java:196) ~[spring-data-redis-2.6.1.jar:2.6.1]
	... 4 common frames omitted

reproduction project and full description can be found at
https://github.com/lrozek/redis-stream-deserialization

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jan 28, 2022
@lrozek
Copy link
Author

lrozek commented Jan 28, 2022

https://github.com/spring-projects/spring-data-redis/blob/main/src/main/java/org/springframework/data/redis/hash/ObjectHashMapper.java#L177

when converter.read is invoked, value for the first param could be provided as StreamMessageListenerContainerOptions#targetType instead of Object.class

@christophstrobl
Copy link
Member

christophstrobl commented Feb 2, 2022

Thanks for reporting! The HashMapper currently does not have means to accept a type argument directly.
We'll look into this matter.

Related to: #2198

@christophstrobl christophstrobl added status: pending-design-work Needs design work before any code can be developed and removed status: waiting-for-triage An issue we've not yet triaged labels Feb 2, 2022
@mp911de mp911de self-assigned this Feb 2, 2022
@mp911de mp911de added status: duplicate A duplicate of another issue and removed status: pending-design-work Needs design work before any code can be developed labels Feb 2, 2022
@mp911de
Copy link
Member

mp911de commented Feb 2, 2022

Closing as duplicate of #2198

@mp911de mp911de closed this as completed Feb 2, 2022
@lrozek
Copy link
Author

lrozek commented Feb 10, 2022

@christophstrobl I noticed that #2253 was merged to main branch and should also fix this issue. When spring-data-redis:2.7.0-SNAPSHOT will be built with your merge to test it ? Any other way to test it before it ?

@christophstrobl
Copy link
Member

@lrozek SNAPSHOT builds are available via repo.spring.io, /libs-snapshot.

@lrozek
Copy link
Author

lrozek commented Feb 10, 2022

@christophstrobl I did use repo.spring.io, /libs-snapshot but snapshot was not built until 10-02-22 11:44:26 that's why I was getting older built.

Now with the latest version I can also confirm that #2253 resolved also this issue. I verified it in repro project with following change to 2.7.0-SNAPSHOT at lrozek/redis-stream-deserialization@fc174cc

What's it the schedule to have 2.7.0 version out?

Thank you

@christophstrobl
Copy link
Member

Glad it works for you now. Please find tentative dates in the release calendar.

@lrozek
Copy link
Author

lrozek commented Feb 10, 2022

@christophstrobl thanks a lot

@lrozek
Copy link
Author

lrozek commented Feb 10, 2022

@christophstrobl according to calendar 2021.2.0 which is for 2.7.0, release candidate no 1 will be released on 14.04.2022. There is no further plans, but anyway it means it will be released after that date. Are there any chances to have this fix earlier, ie backported to 2.6.x line ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: duplicate A duplicate of another issue
Projects
None yet
Development

No branches or pull requests

4 participants