spring-projects / spring-projects/spring-data-redis

`StringRedisConnection` returns `null` using read operations during transactions

Open
#2,953 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type: bug
Dominant language
Java
Stars
1.9k
Forks
1.3k
PR merge metrics
No merged PRs in 30d

Description

A minimize cases as belong, which expect return some value but get null。

    @GetMapping("/get")
    @Transactional
    public String get(@RequestParam String key) {
        String value = stringRedisTemplate.opsForValue().get(key);
        System.out.println(value);
        return value;
    }

DefaultStringConnection hold LettuceRedisConnection with multi = true, result isFutureConversion() always return true

	@Nullable
	private <T> T convertAndReturn(@Nullable Object value, Converter converter) {

		if (isFutureConversion()) {

			addResultConverter(converter);
			return null;
		}

		if (!(converter instanceof ListConverter) && value instanceof List) {
			return (T) new ListConverter<>(converter).convert((List) value);
		}

		return value == null ? null
				: ObjectUtils.nullSafeEquals(converter, Converters.identityConverter()) ? (T) value
						: (T) converter.convert(value);
	}

截屏2024-08-01 下午7 52 26

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with DefaultStringConnection.convertAndReturn and the LettuceRedisConnection transaction path described in the report. Reproduce the shown StringRedisTemplate.opsForValue().get call inside @Transactional, then verify the expected read result and add or update coverage for transaction behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, redis, spring
Domain
backend, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.