Skip to content

Fetch hash field TTLs in seconds in DefaultHashOperations - #3430

Closed
hunseonglee wants to merge 1 commit into
spring-projects:mainfrom
hunseonglee:GH-3427
Closed

hunseonglee wants to merge 1 commit into
spring-projects:mainfrom
hunseonglee:GH-3427

Conversation

@hunseonglee

Copy link
Copy Markdown
Contributor

Closes #3427

getTimeToLive(key, timeUnit, hashKeys) called the unit-aware hTtl(rawKey, timeUnit, rawHashKeys), whose driver implementations already convert the server's seconds into the requested TimeUnit, but then labeled the returned values as seconds (Timeouts.of(TimeUnit.SECONDS, rawValues)), so Expirations converted them a second time. Requesting TimeUnit.MINUTES for a field with a 120-second TTL yielded an expiration of 2 seconds (value() = 0) instead of 2 minutes.

This change uses the unit-less hTtl variant and lets Expirations convert once, matching DefaultReactiveHashOperations. A mock-based regression test added (fails on main with expected: 2M but was: 2S, passes with the fix); the core unit test sweep passes (1409 tests).

getTimeToLive called the unit-aware hTtl variant, whose driver
implementations already convert the server's seconds into the requested
TimeUnit, but then labeled the returned values as seconds for
Expirations, which converted them again. Requesting minutes for a
120-second TTL yielded 2 seconds instead of 2 minutes.

Use the unit-less hTtl variant and let Expirations convert once,
matching the reactive implementation.

Closes spring-projects#3427

Signed-off-by: seonghun lee <harrisleesh@gmail.com>
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Sep 3, 2026
@mhalbritter mhalbritter self-assigned this Sep 7, 2026
@mhalbritter mhalbritter added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels Sep 7, 2026
mhalbritter pushed a commit that referenced this pull request Sep 7, 2026
Use the unit-less hTtl variant and let Expirations convert once,
matching the reactive implementation.

Closes #3427
Original pull request: #3430

Signed-off-by: seonghun lee <harrisleesh@gmail.com>
mhalbritter added a commit that referenced this pull request Sep 7, 2026
See #3427
Original pull request: #3430
mhalbritter pushed a commit that referenced this pull request Sep 7, 2026
Use the unit-less hTtl variant and let Expirations convert once,
matching the reactive implementation.

Closes #3427
Original pull request: #3430

Signed-off-by: seonghun lee <harrisleesh@gmail.com>
mhalbritter added a commit that referenced this pull request Sep 7, 2026
See #3427
Original pull request: #3430
mhalbritter pushed a commit that referenced this pull request Sep 7, 2026
Use the unit-less hTtl variant and let Expirations convert once,
matching the reactive implementation.

Closes #3427
Original pull request: #3430

Signed-off-by: seonghun lee <harrisleesh@gmail.com>
mhalbritter added a commit that referenced this pull request Sep 7, 2026
See #3427
Original pull request: #3430
@mhalbritter mhalbritter added this to the 4.0.8 (2025.1.8) milestone Sep 7, 2026
@mhalbritter

Copy link
Copy Markdown
Contributor

Thanks @harrisleesh, and congrats on your first contribution! This is merged and backported now.

@mhalbritter mhalbritter closed this Sep 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: bug A general bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DefaultHashOperations.getTimeToLive converts hash-field TTL values twice for non-second TimeUnits

3 participants