From f2501e012c5fdeb7ab9bb796d3454da8ca1cf394 Mon Sep 17 00:00:00 2001 From: Artem Bilan Date: Wed, 11 Jul 2018 14:05:25 -0400 Subject: [PATCH] INT-4490: DefaultLockRepo: no uppercase format JIRA https://jira.spring.io/browse/INT-4490 The `DefaultLockRepository.prefix` can be configured with the schema name. And this one can be case-sensitive. * Change format hint from the `%S` to `%s` to avoid upper-casing. **Cherry-pick to 5.0.x and 4.3.x** --- .../jdbc/lock/DefaultLockRepository.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 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 1d23af3fdb..4fe1fcd859 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-2017 the original author or authors. + * Copyright 2016-2018 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. @@ -69,17 +69,17 @@ public class DefaultLockRepository implements LockRepository, InitializingBean { private String region = "DEFAULT"; - private String deleteQuery = "DELETE FROM %SLOCK WHERE REGION=? AND LOCK_KEY=? AND CLIENT_ID=?"; + private String deleteQuery = "DELETE FROM %sLOCK WHERE REGION=? AND LOCK_KEY=? AND CLIENT_ID=?"; - private String deleteExpiredQuery = "DELETE FROM %SLOCK WHERE REGION=? AND LOCK_KEY=? AND CREATED_DATE=?"; + private String countQuery = "SELECT COUNT(REGION) FROM %sLOCK WHERE REGION=? AND LOCK_KEY=? AND CLIENT_ID=? AND CREATED_DATE>=?"; /** * Constructor that initializes the client id that will be associated for @@ -173,8 +173,8 @@ public class DefaultLockRepository implements LockRepository, InitializingBean { new Date(System.currentTimeMillis() - this.ttl)) == 1; } - private int deleteExpired(String lock) { - return this.template.update(this.deleteExpiredQuery, this.region, lock, + private void deleteExpired(String lock) { + this.template.update(this.deleteExpiredQuery, this.region, lock, new Date(System.currentTimeMillis() - this.ttl)); }