Skip to content

Commit f71a223

Browse files
committed
spring-projectsGH-9050: JDBC LockRepository: Use Timestamp instead of LocalDateTime
Fixes: spring-projects#9050 Turns out not all JDBC drivers support a `LocalDateTime` type conversion. * Use `Timestamp.valueOf(LocalDateTime)` for `TIMESTAMP` params of the queries in the `DefaultLockRepository` **Auto-cherry-pick to `6.2.x` & `6.1.x`**
1 parent 91a47cb commit f71a223

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

spring-integration-jdbc/src/main/java/org/springframework/integration/jdbc/lock/DefaultLockRepository.java

+9-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2023 the original author or authors.
2+
* Copyright 2016-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,6 +16,7 @@
1616

1717
package org.springframework.integration.jdbc.lock;
1818

19+
import java.sql.Timestamp;
1920
import java.time.Duration;
2021
import java.time.LocalDateTime;
2122
import java.time.ZoneOffset;
@@ -438,11 +439,15 @@ public boolean renew(String lock) {
438439
return Boolean.TRUE.equals(result);
439440
}
440441

441-
private LocalDateTime ttlEpochMillis() {
442-
return epochMillis().minus(this.ttl);
442+
private Timestamp ttlEpochMillis() {
443+
return Timestamp.valueOf(currentTime().minus(this.ttl));
443444
}
444445

445-
private static LocalDateTime epochMillis() {
446+
private static Timestamp epochMillis() {
447+
return Timestamp.valueOf(currentTime());
448+
}
449+
450+
private static LocalDateTime currentTime() {
446451
return LocalDateTime.now(ZoneOffset.UTC);
447452
}
448453

0 commit comments

Comments
 (0)