From f64b602b23a977c01a0794148ceaf871a0781649 Mon Sep 17 00:00:00 2001 From: Artem Bilan Date: Tue, 20 Jul 2021 09:39:02 -0400 Subject: [PATCH] Fix code smell in the JdbcChannelMessageStore * Refine JavaDocs in the `JdbcChannelMessageStore` --- .../jdbc/store/JdbcChannelMessageStore.java | 35 ++++++++----------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/spring-integration-jdbc/src/main/java/org/springframework/integration/jdbc/store/JdbcChannelMessageStore.java b/spring-integration-jdbc/src/main/java/org/springframework/integration/jdbc/store/JdbcChannelMessageStore.java index f5a172fa8e..80f5efd2a1 100644 --- a/spring-integration-jdbc/src/main/java/org/springframework/integration/jdbc/store/JdbcChannelMessageStore.java +++ b/spring-integration-jdbc/src/main/java/org/springframework/integration/jdbc/store/JdbcChannelMessageStore.java @@ -65,17 +65,14 @@ import org.springframework.util.StringUtils; * database via JDBC. * * This message store shall be used for message channels only. - *

*

* As such, the {@link JdbcChannelMessageStore} uses database specific SQL queries. - *

*

* Contrary to the {@link JdbcMessageStore}, this implementation uses a single database table, * optimized to operate like a queue. * The SQL scripts for creating the table are packaged * under {@code org/springframework/integration/jdbc/schema-*.sql}, * where {@code *} denotes the target database type. - *

* * @author Gunnar Hillert * @author Artem Bilan @@ -114,6 +111,8 @@ public class JdbcChannelMessageStore implements PriorityCapableChannelMessageSto DELETE_MESSAGE } + private final Map queryCache = new ConcurrentHashMap<>(); + private final Set idCache = new HashSet<>(); private final ReadWriteLock idCacheLock = new ReentrantReadWriteLock(); @@ -140,8 +139,6 @@ public class JdbcChannelMessageStore implements PriorityCapableChannelMessageSto private ChannelMessageStorePreparedStatementSetter preparedStatementSetter; - private final Map queryCache = new ConcurrentHashMap<>(); - private MessageGroupFactory messageGroupFactory = new SimpleMessageGroupFactory(); private boolean usingIdCache = false; @@ -229,7 +226,7 @@ public class JdbcChannelMessageStore implements PriorityCapableChannelMessageSto } /** - * Allows for passing in a custom {@link MessageRowMapper}. The {@link MessageRowMapper} + * Allow for passing in a custom {@link MessageRowMapper}. The {@link MessageRowMapper} * is used to convert the selected database row representing the persisted * message into the actual {@link Message} object. * @param messageRowMapper Must not be null @@ -252,7 +249,7 @@ public class JdbcChannelMessageStore implements PriorityCapableChannelMessageSto } /** - * Sets the database specific {@link ChannelMessageStoreQueryProvider} to use. + * Set the database specific {@link ChannelMessageStoreQueryProvider} to use. * The {@link JdbcChannelMessageStore} provides the SQL queries to retrieve messages from * the database. See the JavaDocs {@link ChannelMessageStoreQueryProvider} (all known * implementing classes) to see those implementations provided by the framework. @@ -269,7 +266,7 @@ public class JdbcChannelMessageStore implements PriorityCapableChannelMessageSto /** * A unique grouping identifier for all messages persisted with this store. * Using multiple regions allows the store to be partitioned (if necessary) - * for different purposes. Defaults to {@link #DEFAULT_REGION}. + * for different purposes. Defaults to {@link #DEFAULT_REGION}. * @param region the region name to set */ public void setRegion(String region) { @@ -333,7 +330,7 @@ public class JdbcChannelMessageStore implements PriorityCapableChannelMessageSto * * } * - * @param usingIdCache When true the id cache will be used. + * @param usingIdCache When {@code true} the id cache will be used. */ public void setUsingIdCache(boolean usingIdCache) { this.usingIdCache = usingIdCache; @@ -439,9 +436,8 @@ public class JdbcChannelMessageStore implements PriorityCapableChannelMessageSto } /** - * Method not implemented. + * Return the number of message groups in the store for configured region. * @return The message group count. - * @throws UnsupportedOperationException Method not supported. */ @ManagedAttribute public int getMessageGroupCount() { @@ -465,7 +461,7 @@ public class JdbcChannelMessageStore implements PriorityCapableChannelMessageSto } /** - * Returns the number of messages persisted for the specified channel id (groupId) + * Return the number of messages persisted for the specified channel id (groupId) * and the specified region ({@link #setRegion(String)}). * @return The message group size. */ @@ -488,7 +484,7 @@ public class JdbcChannelMessageStore implements PriorityCapableChannelMessageSto } /** - * Polls the database for a new message that is persisted for the given + * Poll the database for a new message that is persisted for the given * group id which represents the channel identifier. */ @Override @@ -582,21 +578,20 @@ public class JdbcChannelMessageStore implements PriorityCapableChannelMessageSto boolean result = updated != 0; if (result) { - LOGGER.debug(LogMessage.format("Message with id '%s' was deleted.", id)); + LOGGER.debug(() -> "Message with id '" + id + "' was deleted."); } else { - LOGGER.warn(LogMessage.format("Message with id '%s' was not deleted.", id)); + LOGGER.warn(() -> "Message with id '" + id + "' was not deleted."); } return result; } /** - *

Remove a Message Id from the idCache. Should be used in conjunction + * Remove a Message Id from the idCache. Should be used in conjunction * with the Spring Integration Transaction Synchronization feature to remove * a message from the Message Id cache once a transaction either succeeded or - * rolled back.

- *

Only applicable if {@link #setUsingIdCache(boolean)} is set to - * true

. + * rolled back. + * Only applicable if {@link #setUsingIdCache(boolean)} is set to{@code true}. * @param messageId The message identifier. */ public void removeFromIdCache(String messageId) { @@ -611,7 +606,7 @@ public class JdbcChannelMessageStore implements PriorityCapableChannelMessageSto } /** - * Returns the size of the Message Id Cache, which caches Message Ids for + * Return the size of the Message Id Cache, which caches Message Ids for * those messages that are currently being processed. * @return The size of the Message Id Cache */