[BUG]Spring RedisTemplate使用GenericFastJsonRedisSerializer后,对于put后的值,不能increment
- Dominant language
- Java
- Stars
- 4.4k
- Forks
- 613
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 6
Description
### 问题描述
把GenericFastJsonRedisSerializer配置到RedisTemplate之后,如果put一个Long类型的值作为初始值,比如: 1L,随后执行increment,会报:ERR value is not an integer or out of range
### 期待的正确结果
使用GenericFastJsonRedisSerializer后,可以用Long去初始化redis的value,不会影响后继的increment操作。
#### 附加信息
出错后,查看redis发现其值为字符串“1L”,而不是“1”,redis无法对“1L”进行处理。和jackson对比:
```java
public static void main(String[] args) throws JsonProcessingException {
Long n = 1L;
// fastjson2
System.out.println(JSON.toJSONString(n, JSONWriter.Feature.WriteClassName));
// jackson
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
objectMapper.activateDefaultTyping(LaissezFaireSubTypeValidator.instance, ObjectMapper.DefaultTyping.NON_FINAL);
System.out.println(objectMapper.writeValueAsString(n));
}
===========
// output:
1L
1
```
Contributor guide
Research direction
Start by locating the GenericFastJsonRedisSerializer integration used with Spring RedisTemplate and reproduce the Long put-then-increment case against Redis. Compare the stored value with the expected Redis integer representation and verify that initializing with 1L no longer prevents increment; the issue provides no file or test path.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, redis, spring
- Domain
- backend, databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100