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 mapper in type resolver #2991

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,10 @@ public GenericJackson2JsonRedisSerializer configure(Consumer<ObjectMapper> objec
return this;
}

public void setCustomMapperForTypeResolver(ObjectMapper mapper) {
this.typeResolver.setCustomObjectMapper(mapper);
}

protected JavaType resolveType(byte[] source, Class<?> type) throws IOException {

if (!type.equals(Object.class) || !defaultTypingEnabled.get()) {
Expand All @@ -341,7 +345,7 @@ protected JavaType resolveType(byte[] source, Class<?> type) throws IOException
static class TypeResolver {

// need a separate instance to bypass class hint checks
private final ObjectMapper mapper = new ObjectMapper();
private ObjectMapper mapper = new ObjectMapper();

private final Supplier<TypeFactory> typeFactory;
private final Supplier<String> hintName;
Expand All @@ -367,6 +371,10 @@ protected JavaType resolveType(byte[] source, Class<?> type) throws IOException

return constructType(type);
}

public void setCustomObjectMapper(ObjectMapper mapper) {
this.mapper = mapper;
}
}

/**
Expand Down