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 f71a2234d8)
This commit is contained in:
committed by
Spring Builds
parent
707c9646fa
commit
ced33d8065
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2023 the original author or authors.
|
||||
* Copyright 2016-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.springframework.integration.jdbc.lock;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.time.Duration;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneOffset;
|
||||
@@ -438,11 +439,15 @@ public class DefaultLockRepository
|
||||
return Boolean.TRUE.equals(result);
|
||||
}
|
||||
|
||||
private LocalDateTime ttlEpochMillis() {
|
||||
return epochMillis().minus(this.ttl);
|
||||
private Timestamp ttlEpochMillis() {
|
||||
return Timestamp.valueOf(currentTime().minus(this.ttl));
|
||||
}
|
||||
|
||||
private static LocalDateTime epochMillis() {
|
||||
private static Timestamp epochMillis() {
|
||||
return Timestamp.valueOf(currentTime());
|
||||
}
|
||||
|
||||
private static LocalDateTime currentTime() {
|
||||
return LocalDateTime.now(ZoneOffset.UTC);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user