Skip to content

Commit 2d00cb7

Browse files
artembilanspring-builds
authored andcommitted
GH-9050: JDBC LockRepository: Use Timestamp instead of LocalDateTime
Fixes: #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` (cherry picked from commit f71a223)
1 parent 9f19f40 commit 2d00cb7

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

Lines changed: 9 additions & 4 deletions
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;
@@ -382,11 +383,15 @@ public boolean renew(String lock) {
382383
return Boolean.TRUE.equals(result);
383384
}
384385

385-
private LocalDateTime ttlEpochMillis() {
386-
return epochMillis().minus(this.ttl);
386+
private Timestamp ttlEpochMillis() {
387+
return Timestamp.valueOf(currentTime().minus(this.ttl));
387388
}
388389

389-
private static LocalDateTime epochMillis() {
390+
private static Timestamp epochMillis() {
391+
return Timestamp.valueOf(currentTime());
392+
}
393+
394+
private static LocalDateTime currentTime() {
390395
return LocalDateTime.now(ZoneOffset.UTC);
391396
}
392397

0 commit comments

Comments
 (0)