Closed as not planned
Description
Here's a code example of the problem I ran into.
I use the RedisSerializer serialize a Object,but ican't deserialize it.
public static void main(String[] args) {
GenericJackson2JsonRedisSerializer serializer = new GenericJackson2JsonRedisSerializer();
serializer.configure(objectMapper -> objectMapper.registerModule(new JavaTimeModule()));
String[] a = new String[]{"1", "2"};
byte[] serialize = serializer.serialize(a);
System.out.println(new String(serialize, StandardCharsets.UTF_8));
try {
System.out.println(serializer.deserialize(serialize));
} catch (Exception e) {
System.err.println(e.getMessage());
}
//unmodifiableList
List<String> collect = Arrays.stream(a).toList();
serialize = serializer.serialize(collect);
System.out.println(new String(serialize, StandardCharsets.UTF_8));
try {
System.out.println(serializer.deserialize(serialize));
} catch (Exception e) {
System.err.println(e.getMessage());
}
//ArrayList
collect = Arrays.stream(a).collect(Collectors.toList());
serialize = serializer.serialize(collect);
System.out.println(new String(serialize, StandardCharsets.UTF_8));
try {
System.out.println(serializer.deserialize(serialize));
} catch (Exception e) {
System.err.println(e.getMessage());
}
}
Executing the above code gives the following result:
- Array deserialization failed
- unmodifiableList deserialization failed
- ArrayList was deserialized successfully
After debugging, I found that the code in the figure is causing this problem. It looks like it is filtering out some basic types, but why should it be written like this, so it is not causing some problems now? Can anyone help with that? Thank you very much