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

Support custom NullValueSerializer in GenericJackson2JsonRedisSerializer #2878

Closed
ekeric13 opened this issue Mar 22, 2024 · 1 comment
Closed
Assignees
Labels
status: ideal-for-contribution An issue that a contributor can help us with type: enhancement A general enhancement

Comments

@ekeric13
Copy link

ekeric13 commented Mar 22, 2024

If one wants a custom NullValueSerializer you can define your own registerNullValueSerializer, you cannot define your own NullValueSerializer

but because registerNullValueSerializer is static, you have to also overwrite other methods like the base constructors.

so how can one easily define their own nullValueSerializer?
the use case in particular i am using it as redis is used as the backend for @cachable and i want to cache the fact that i have a null value for some keys. the default null that the redis serializer uses is jsonGenerator.writeStringField(classIdentifier, NullValue.class.getName());, which produces a weird byte array that when i try to deserialize it (access the cache later) it gives me an error.

And then semi-related, if i overwrite the deserialize method to return null if i see the special null identifier, @cacheable considers it a cache miss. but i actually really do want to return the value null from my cache!!

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Mar 22, 2024
@ekeric13 ekeric13 changed the title For GenericJackson2JsonRedisSerializer custom NullValueSerializer For GenericJackson2JsonRedisSerializer use custom NullValueSerializer Mar 22, 2024
@christophstrobl christophstrobl added status: ideal-for-contribution An issue that a contributor can help us with type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Mar 25, 2024
@AnneMayor
Copy link
Contributor

May I handle this issue? I'll create PR on this weekend :)

@mp911de mp911de changed the title For GenericJackson2JsonRedisSerializer use custom NullValueSerializer Support custom NullValueSerializer in GenericJackson2JsonRedisSerializer May 21, 2024
mp911de added a commit that referenced this issue May 21, 2024
Revise builder. Accept builder components in builder methods instead of the builder factory method. Enforce valid parameters instead of lenient, potentially null parameters.

Introduce configuration means to control default typing. Extend tests.

See #2878
Original pull request: #2905
mp911de pushed a commit that referenced this issue May 21, 2024
mp911de added a commit that referenced this issue May 21, 2024
Revise builder. Accept builder components in builder methods instead of the builder factory method. Enforce valid parameters instead of lenient, potentially null parameters.

Introduce configuration means to control default typing. Extend tests.

See #2878
Original pull request: #2905
@mp911de mp911de added this to the 3.3.1 (2024.0.1) milestone May 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: ideal-for-contribution An issue that a contributor can help us with type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants