From ced33d806543cfd6ed7c7f8694e9d29d48861efd Mon Sep 17 00:00:00 2001 From: Artem Bilan Date: Mon, 25 Mar 2024 13:12:11 -0400 Subject: [PATCH] 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 f71a2234d866a6a57151df11dc74984bdc9f6d95) --- .../jdbc/lock/DefaultLockRepository.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/spring-integration-jdbc/src/main/java/org/springframework/integration/jdbc/lock/DefaultLockRepository.java b/spring-integration-jdbc/src/main/java/org/springframework/integration/jdbc/lock/DefaultLockRepository.java index cb56035861..e442a6d125 100644 --- a/spring-integration-jdbc/src/main/java/org/springframework/integration/jdbc/lock/DefaultLockRepository.java +++ b/spring-integration-jdbc/src/main/java/org/springframework/integration/jdbc/lock/DefaultLockRepository.java @@ -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); }