Skip to content

JDBC lock repository fails after entering daylight savings #10906

@Martin-den-Heijer

Description

@Martin-den-Heijer

In what version(s) of Spring Integration are you seeing this issue?

6.0.0-M5 and later. The bug was introduced in the code change for #3885.

Describe the bug

When the default timezone has daylight savings, then locks can fail after entering daylight savings (and likely also after leaving). The window for this bug to occur depends on the offset of the time zone.

To Reproduce

This problem cannot be reproduced reliably, but it's cause can be demonstrated using jshell.

The problem is caused by the following code in DefaultLockRepository.java

private Timestamp ttlEpochMillis(Duration ttl) {
	return Timestamp.valueOf(currentTime().plus(ttl));
}

private static Timestamp epochMillis() {
	return Timestamp.valueOf(currentTime());
}

private static LocalDateTime currentTime() {
	return LocalDateTime.now(ZoneOffset.UTC);
}

The Timestamp.valueOf method uses the system default time zone, which is Europe/Amsterdam in our case. This does not cause problems most of the time, but some LocalDateTime values are invalid because the forward adjustment of the clock when entering daylight savings. This may cause the timestamp stored in the database to jump back and forth. For example :

jshell> java.time.ZoneId.systemDefault()
$1 ==> Europe/Amsterdam

jshell> java.sql.Timestamp.valueOf(java.time.LocalDateTime.of(2026,3,29,2,59,59,999999999))
$2 ==> 2026-03-29 03:59:59.999999999

jshell> java.sql.Timestamp.valueOf(java.time.LocalDateTime.of(2026,3,29,3,0,0))
$3 ==> 2026-03-29 03:00:00.0

The demonstrated jump back in time breaks the lock temporarily because there is a short window where non-lock-owners may see an expired lock.

Expected behavior

The generated timestamps should be correct, even during daylight savings transitions.

Sample

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions