diff --git a/spring-integration-core/src/main/java/org/springframework/integration/aggregator/CorrelatingMessageBarrier.java b/spring-integration-core/src/main/java/org/springframework/integration/aggregator/CorrelatingMessageBarrier.java index a418cc88b59..560ef7f1f32 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/aggregator/CorrelatingMessageBarrier.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/aggregator/CorrelatingMessageBarrier.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2021 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. @@ -20,6 +20,7 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; +import org.springframework.core.log.LogMessage; import org.springframework.integration.core.MessageSource; import org.springframework.integration.handler.AbstractMessageHandler; import org.springframework.integration.store.MessageGroup; @@ -47,6 +48,7 @@ * @author Oleg Zhurakousky * @author Gary Russell * @author Artem Bilan + * @author Trung Pham * * @see AbstractCorrelatingMessageHandler */ @@ -93,9 +95,7 @@ protected void handleMessageInternal(Message message) { synchronized (lock) { this.store.addMessagesToGroup(correlationKey, message); } - if (logger.isDebugEnabled()) { - logger.debug(String.format("Handled message for key [%s]: %s.", correlationKey, message)); - } + logger.debug(LogMessage.format("Handled message for key [%s]: %s.", correlationKey, message)); } private Object getLock(Object correlationKey) { @@ -119,9 +119,7 @@ public Message receive() { if (messages.hasNext()) { nextMessage = messages.next(); this.store.removeMessagesFromGroup(key, nextMessage); - if (logger.isDebugEnabled()) { - logger.debug(String.format("Released message for key [%s]: %s.", key, nextMessage)); - } + logger.debug(LogMessage.format("Released message for key [%s]: %s.", key, nextMessage)); } else { remove(key); diff --git a/spring-integration-core/src/main/java/org/springframework/integration/channel/AbstractPollableChannel.java b/spring-integration-core/src/main/java/org/springframework/integration/channel/AbstractPollableChannel.java index 61c9b3d45ac..db0d4ad85d1 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/channel/AbstractPollableChannel.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/channel/AbstractPollableChannel.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2021 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. @@ -20,6 +20,7 @@ import java.util.Deque; import java.util.List; +import org.springframework.core.log.LogMessage; import org.springframework.integration.IntegrationPatternType; import org.springframework.integration.support.management.metrics.CounterFacade; import org.springframework.integration.support.management.metrics.MetricsCaptor; @@ -36,6 +37,7 @@ * @author Artem Bilan * @author Gary Russell * @author Artem Bilan + * @author Trung Pham */ public abstract class AbstractPollableChannel extends AbstractMessageChannel implements PollableChannel, ExecutorChannelInterceptorAware { @@ -99,10 +101,7 @@ public Message receive(long timeout) { else { incrementReceiveCounter(); counted = true; - - if (logger.isDebugEnabled()) { - logger.debug("postReceive on channel '" + this + "', message: " + message); - } + logger.debug(LogMessage.format("postReceive on channel '%s', message: %s", this, message)); } if (interceptorStack != null && message != null) { diff --git a/spring-integration-core/src/main/java/org/springframework/integration/channel/DefaultHeaderChannelRegistry.java b/spring-integration-core/src/main/java/org/springframework/integration/channel/DefaultHeaderChannelRegistry.java index c508e5e48cd..040394e2629 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/channel/DefaultHeaderChannelRegistry.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/channel/DefaultHeaderChannelRegistry.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2020 the original author or authors. + * Copyright 2013-2021 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. @@ -43,6 +43,7 @@ * * @author Gary Russell * @author Artem Bilan + * @author Trung Pham * * @since 3.0 * @@ -166,9 +167,7 @@ public Object channelToChannelName(@Nullable Object channel, long timeToLive) { String name = this.uuid + id.incrementAndGet(); this.channels.put(name, new MessageChannelWrapper((MessageChannel) channel, System.currentTimeMillis() + timeToLive)); - if (logger.isDebugEnabled()) { - logger.debug("Registered " + channel + " as " + name); - } + logger.debug(() -> "Registered " + channel + " as " + name); return name; } else { @@ -187,8 +186,8 @@ public MessageChannel channelNameToChannel(@Nullable String name) { else { messageChannelWrapper = this.channels.get(name); } - if (logger.isDebugEnabled() && messageChannelWrapper != null) { - logger.debug("Retrieved " + messageChannelWrapper.getChannel() + " with " + name); + if (messageChannelWrapper != null) { + logger.debug(() -> "Retrieved " + messageChannelWrapper.getChannel() + " with " + name); } return messageChannelWrapper == null ? null : messageChannelWrapper.getChannel(); @@ -211,17 +210,13 @@ public synchronized void runReaper() { @Override public synchronized void run() { - if (logger.isTraceEnabled()) { - logger.trace("Reaper started; channels size=" + this.channels.size()); - } + logger.trace(() -> "Reaper started; channels size=" + this.channels.size()); Iterator> iterator = this.channels.entrySet().iterator(); long now = System.currentTimeMillis(); while (iterator.hasNext()) { Entry entry = iterator.next(); if (entry.getValue().getExpireAt() < now) { - if (logger.isDebugEnabled()) { - logger.debug("Expiring " + entry.getKey() + " (" + entry.getValue().getChannel() + ")"); - } + logger.debug(() -> "Expiring " + entry.getKey() + " (" + entry.getValue().getChannel() + ")"); iterator.remove(); } } @@ -229,9 +224,7 @@ public synchronized void run() { getTaskScheduler() .schedule(this, new Date(System.currentTimeMillis() + this.reaperDelay)); - if (logger.isTraceEnabled()) { - logger.trace("Reaper completed; channels size=" + this.channels.size()); - } + logger.trace(() -> "Reaper completed; channels size=" + this.channels.size()); } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/channel/PublishSubscribeChannel.java b/spring-integration-core/src/main/java/org/springframework/integration/channel/PublishSubscribeChannel.java index c8a360798a9..e868151d130 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/channel/PublishSubscribeChannel.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/channel/PublishSubscribeChannel.java @@ -34,6 +34,7 @@ * @author Oleg Zhurakousky * @author Gary Russell * @author Artem Bilan + * @author Trung Pham */ public class PublishSubscribeChannel extends AbstractExecutorChannel implements BroadcastCapableChannel { @@ -180,8 +181,8 @@ public final void onInit() { dispatcherToUse.setMinSubscribers(this.minSubscribers); this.dispatcher = dispatcherToUse; } - else if (this.errorHandler != null && this.logger.isWarnEnabled()) { - this.logger.warn("The 'errorHandler' is ignored for the '" + getComponentName() + + else if (this.errorHandler != null) { + this.logger.warn(() -> "The 'errorHandler' is ignored for the '" + getComponentName() + "' (an 'executor' is not provided) and exceptions will be thrown " + "directly within the sending Thread"); } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/endpoint/AbstractEndpoint.java b/spring-integration-core/src/main/java/org/springframework/integration/endpoint/AbstractEndpoint.java index 16801cc6995..d68930047c2 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/endpoint/AbstractEndpoint.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/endpoint/AbstractEndpoint.java @@ -44,6 +44,7 @@ * @author Kris Jacyna * @author Gary Russell * @author Artem Bilan + * @author Trung Pham */ @IntegrationManagedResource public abstract class AbstractEndpoint extends IntegrationObjectSupport @@ -155,9 +156,7 @@ public final void start() { this.active = true; doStart(); this.running = true; - if (logger.isInfoEnabled()) { - logger.info("started " + this); - } + logger.info(() -> "started " + this); } } finally { @@ -173,9 +172,7 @@ public final void stop() { this.active = false; doStop(); this.running = false; - if (logger.isInfoEnabled()) { - logger.info("stopped " + this); - } + logger.info(() -> "stopped " + this); } } finally { @@ -191,9 +188,7 @@ public final void stop(Runnable callback) { this.active = false; doStop(callback); this.running = false; - if (logger.isInfoEnabled()) { - logger.info("stopped " + this); - } + logger.info(() -> "stopped " + this); } else { callback.run(); diff --git a/spring-integration-core/src/main/java/org/springframework/integration/endpoint/ReactiveStreamsConsumer.java b/spring-integration-core/src/main/java/org/springframework/integration/endpoint/ReactiveStreamsConsumer.java index c509ca3f596..35dc6753cf8 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/endpoint/ReactiveStreamsConsumer.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/endpoint/ReactiveStreamsConsumer.java @@ -49,6 +49,7 @@ * input channel and reactive consumption of messages from that channel. * * @author Artem Bilan + * @author Trung Pham * * @since 5.0 */ @@ -89,7 +90,7 @@ public ReactiveStreamsConsumer(MessageChannel inputChannel, Subscriber "failure occurred in gateway sendAndReceive: " + ex.getMessage()); reply = ex; if (sample != null) { sample.stop(buildSendTimer(false, ex.getClass().getSimpleName())); @@ -708,9 +707,7 @@ private Mono> buildReplyMono(Message requestMessage, Mono> handleSendError(Message requestMessage, Throwable exception) { - if (logger.isDebugEnabled()) { - logger.debug("failure occurred in gateway sendAndReceiveReactive: " + exception.getMessage()); - } + logger.debug(() -> "failure occurred in gateway sendAndReceiveReactive: " + exception.getMessage()); MessageChannel channel = getErrorChannel(); if (channel != null) { ErrorMessage errorMessage = buildErrorMessage(requestMessage, exception); diff --git a/spring-integration-core/src/main/java/org/springframework/integration/handler/AbstractReactiveMessageHandler.java b/spring-integration-core/src/main/java/org/springframework/integration/handler/AbstractReactiveMessageHandler.java index da8dd268246..3bee00f28a5 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/handler/AbstractReactiveMessageHandler.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/handler/AbstractReactiveMessageHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2019-2020 the original author or authors. + * Copyright 2019-2021 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.handler; +import org.springframework.core.log.LogMessage; import org.springframework.integration.history.MessageHistory; import org.springframework.messaging.Message; import org.springframework.messaging.ReactiveMessageHandler; @@ -28,6 +29,7 @@ * * @author David Turanski * @author Artem Bilan + * @author Trung Pham * * @since 5.3 */ @@ -37,8 +39,8 @@ public abstract class AbstractReactiveMessageHandler extends MessageHandlerSuppo @Override public Mono handleMessage(final Message message) { Assert.notNull(message, "message must not be null"); - if (isLoggingEnabled() && this.logger.isDebugEnabled()) { - this.logger.debug(this + " received message: " + message); + if (isLoggingEnabled()) { + this.logger.debug(LogMessage.format("%s received message: %s", this, message)); } final Message messageToUse; @@ -49,8 +51,8 @@ public Mono handleMessage(final Message message) { messageToUse = message; } return handleMessageInternal(messageToUse) - .doOnError((ex) -> this.logger.error(ex, () -> - "An error occurred in message handler [" + this + "] on message [" + messageToUse + "]")); + .doOnError((ex) -> this.logger.error(ex, + LogMessage.format("An error occurred in message handler [%s] on message [%s]", this, messageToUse))); } protected abstract Mono handleMessageInternal(Message message); diff --git a/spring-integration-core/src/main/java/org/springframework/integration/handler/AbstractReplyProducingMessageHandler.java b/spring-integration-core/src/main/java/org/springframework/integration/handler/AbstractReplyProducingMessageHandler.java index 79efba71c3b..d6134f07764 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/handler/AbstractReplyProducingMessageHandler.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/handler/AbstractReplyProducingMessageHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2021 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. @@ -23,6 +23,7 @@ import org.springframework.aop.framework.ProxyFactory; import org.springframework.beans.factory.BeanClassLoaderAware; +import org.springframework.core.log.LogMessage; import org.springframework.integration.IntegrationPatternType; import org.springframework.integration.handler.advice.HandleMessageAdvice; import org.springframework.lang.Nullable; @@ -39,6 +40,7 @@ * @author Gary Russell * @author Artem Bilan * @author David Liu + * @author Trung Pham */ public abstract class AbstractReplyProducingMessageHandler extends AbstractMessageProducingHandler implements BeanClassLoaderAware { @@ -143,8 +145,8 @@ else if (this.requiresReply && !isAsync()) { throw new ReplyRequiredException(message, "No reply produced by handler '" + getComponentName() + "', and its 'requiresReply' property is set to true."); } - else if (!isAsync() && logger.isDebugEnabled()) { - logger.debug("handler '" + this + "' produced no reply for request Message: " + message); + else if (!isAsync()) { + logger.debug(LogMessage.format("handler '%s' produced no reply for request Message: %s", this, message)); } } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/handler/MessageHandlerChain.java b/spring-integration-core/src/main/java/org/springframework/integration/handler/MessageHandlerChain.java index a05656d0433..eeae70cffb2 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/handler/MessageHandlerChain.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/handler/MessageHandlerChain.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2021 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. @@ -65,6 +65,7 @@ * @author Iwein Fuld * @author Gary Russell * @author Artem Bilan + * @author Trung Pham */ public class MessageHandlerChain extends AbstractMessageProducingHandler implements CompositeMessageHandler, ManageableLifecycle { @@ -182,9 +183,7 @@ public final void start() { if (!this.running) { doStart(); this.running = true; - if (logger.isInfoEnabled()) { - logger.info("started " + this); - } + logger.info(() -> "started " + this); } } finally { @@ -199,9 +198,7 @@ public final void stop() { if (this.running) { doStop(); this.running = false; - if (logger.isInfoEnabled()) { - logger.info("stopped " + this); - } + logger.info(() -> "stopped " + this); } } finally { diff --git a/spring-integration-core/src/main/java/org/springframework/integration/handler/advice/RequestHandlerCircuitBreakerAdvice.java b/spring-integration-core/src/main/java/org/springframework/integration/handler/advice/RequestHandlerCircuitBreakerAdvice.java index df86312a91d..85ac4bd49c1 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/handler/advice/RequestHandlerCircuitBreakerAdvice.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/handler/advice/RequestHandlerCircuitBreakerAdvice.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2021 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. @@ -30,6 +30,7 @@ * * @author Gary Russell * @author Artem Bilan + * @author Trung Pham * * @since 2.2 * @@ -73,8 +74,8 @@ protected Object doInvoke(ExecutionCallback callback, Object target, Message } try { Object result = callback.execute(); - if (logger.isDebugEnabled() && metadata.getFailures().get() > 0) { - logger.debug("Closing Circuit Breaker for " + target); + if (metadata.getFailures().get() > 0) { + logger.debug(() -> "Closing Circuit Breaker for " + target); } metadata.getFailures().set(0); return result; diff --git a/spring-integration-core/src/main/java/org/springframework/integration/handler/support/MessagingMethodInvokerHelper.java b/spring-integration-core/src/main/java/org/springframework/integration/handler/support/MessagingMethodInvokerHelper.java index 6615f9b5fb0..c525a48f59a 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/handler/support/MessagingMethodInvokerHelper.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/handler/support/MessagingMethodInvokerHelper.java @@ -118,6 +118,7 @@ * @author Soby Chacko * @author Gary Russell * @author Artem Bilan + * @author Trung Pham * * @since 2.0 */ @@ -830,8 +831,8 @@ private boolean isPausableMethod(Method pausableMethod) { || Lifecycle.class.isAssignableFrom(declaringClass)) && ReflectionUtils.findMethod(Pausable.class, pausableMethod.getName(), pausableMethod.getParameterTypes()) != null; - if (pausable && this.logger.isTraceEnabled()) { - this.logger.trace(pausableMethod + " is not considered a candidate method unless explicitly requested"); + if (pausable) { + this.logger.trace(() -> pausableMethod + " is not considered a candidate method unless explicitly requested"); } return pausable; } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/router/AbstractMappingMessageRouter.java b/spring-integration-core/src/main/java/org/springframework/integration/router/AbstractMappingMessageRouter.java index e43b10dccbe..6b87000ec73 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/router/AbstractMappingMessageRouter.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/router/AbstractMappingMessageRouter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2021 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. @@ -28,6 +28,7 @@ import java.util.Set; import org.springframework.core.convert.ConversionService; +import org.springframework.core.log.LogMessage; import org.springframework.integration.support.management.MappingMessageRouterManagement; import org.springframework.jmx.export.annotation.ManagedAttribute; import org.springframework.jmx.export.annotation.ManagedOperation; @@ -47,6 +48,7 @@ * @author Gunnar Hillert * @author Gary Russell * @author Artem Bilan + * @author Trung Pham * * @since 2.1 */ @@ -230,9 +232,7 @@ public void replaceChannelMappings(Properties channelMappings) { private void doSetChannelMappings(Map newChannelMappings) { Map oldChannelMappings = this.channelMappings; this.channelMappings = newChannelMappings; - if (logger.isDebugEnabled()) { - logger.debug("Channel mappings: " + oldChannelMappings + " replaced with: " + newChannelMappings); - } + logger.debug(LogMessage.format("Channel mappings: %s replaced with: %s", oldChannelMappings, newChannelMappings)); } private MessageChannel resolveChannelForName(String channelName, Message message) { diff --git a/spring-integration-core/src/main/java/org/springframework/integration/transformer/ClaimCheckOutTransformer.java b/spring-integration-core/src/main/java/org/springframework/integration/transformer/ClaimCheckOutTransformer.java index 3af648c21c3..5a5cbe53489 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/transformer/ClaimCheckOutTransformer.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/transformer/ClaimCheckOutTransformer.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2021 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. @@ -18,6 +18,7 @@ import java.util.UUID; +import org.springframework.core.log.LogMessage; import org.springframework.integration.IntegrationPattern; import org.springframework.integration.IntegrationPatternType; import org.springframework.integration.store.MessageStore; @@ -34,6 +35,7 @@ * @author Oleg Zhurakousky * @author Nick Spacek * @author Artem Bilan + * @author Trung Pham * * @since 2.0 */ @@ -76,9 +78,7 @@ protected Object doTransform(Message message) { Message retrievedMessage; if (this.removeMessage) { retrievedMessage = this.messageStore.removeMessage(id); - if (logger.isDebugEnabled()) { - logger.debug("Removed Message with claim-check '" + id + "' from the MessageStore."); - } + logger.debug(LogMessage.format("Removed Message with claim-check '%s' from the MessageStore.", id)); } else { retrievedMessage = this.messageStore.getMessage(id); diff --git a/spring-integration-core/src/main/java/org/springframework/integration/transformer/HeaderEnricher.java b/spring-integration-core/src/main/java/org/springframework/integration/transformer/HeaderEnricher.java index 4393c274f5b..9a792f86461 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/transformer/HeaderEnricher.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/transformer/HeaderEnricher.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2021 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. @@ -43,6 +43,7 @@ * @author David Turanski * @author Artem Bilan * @author Gary Russell + * @author Trung Pham */ public class HeaderEnricher extends IntegrationObjectSupport implements Transformer, IntegrationPattern { @@ -113,8 +114,8 @@ public void onInit() { ((BeanFactoryAware) this.messageProcessor).setBeanFactory(beanFactory); } - if (!shouldOverwrite && !this.shouldSkipNulls && logger.isWarnEnabled()) { - logger.warn(getComponentName() + + if (!shouldOverwrite && !this.shouldSkipNulls) { + logger.warn(() -> getComponentName() + " is configured to not overwrite existing headers. 'shouldSkipNulls = false' will have no effect"); } } @@ -192,13 +193,13 @@ private void addHeadersFromMessageProcessor(Message message, messageBuilder.setHeader((String) key, entry.getValue()); } } - else if (logger.isDebugEnabled()) { - logger.debug("ignoring value for non-String key: " + key); + else { + logger.debug(() -> "ignoring value for non-String key: " + key); } } } - else if (logger.isDebugEnabled()) { - logger.debug("expected a Map result from processor, but received: " + result); + else { + logger.debug(() -> "expected a Map result from processor, but received: " + result); } } } diff --git a/spring-integration-file/src/main/java/org/springframework/integration/file/FileWritingMessageHandler.java b/spring-integration-file/src/main/java/org/springframework/integration/file/FileWritingMessageHandler.java index 841893cdbc9..0aa17becbce 100644 --- a/spring-integration-file/src/main/java/org/springframework/integration/file/FileWritingMessageHandler.java +++ b/spring-integration-file/src/main/java/org/springframework/integration/file/FileWritingMessageHandler.java @@ -107,6 +107,7 @@ * @author Gary Russell * @author Tony Falabella * @author Alen Turkovic + * @author Trung Pham */ public class FileWritingMessageHandler extends AbstractReplyProducingMessageHandler implements ManageableLifecycle, MessageTriggerAction { @@ -588,8 +589,8 @@ else if (payload instanceof String) { + "' timestamp on file: " + fileToReturn); } } - else if (this.logger.isWarnEnabled()) { - this.logger.warn("Could not set lastModified, header " + FileHeaders.SET_MODIFIED + else { + this.logger.warn(() -> "Could not set lastModified, header " + FileHeaders.SET_MODIFIED + " must be a Number, not " + (timestamp == null ? "null" : timestamp.getClass())); } } diff --git a/spring-integration-file/src/main/java/org/springframework/integration/file/remote/AbstractRemoteFileStreamingMessageSource.java b/spring-integration-file/src/main/java/org/springframework/integration/file/remote/AbstractRemoteFileStreamingMessageSource.java index 09595e81c4d..30052f48dc5 100644 --- a/spring-integration-file/src/main/java/org/springframework/integration/file/remote/AbstractRemoteFileStreamingMessageSource.java +++ b/spring-integration-file/src/main/java/org/springframework/integration/file/remote/AbstractRemoteFileStreamingMessageSource.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 the original author or authors. + * Copyright 2016-2021 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. @@ -29,6 +29,7 @@ import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; +import org.springframework.core.log.LogMessage; import org.springframework.expression.Expression; import org.springframework.expression.common.LiteralExpression; import org.springframework.integration.IntegrationMessageHeaderAccessor; @@ -51,6 +52,7 @@ * @author Gary Russell * @author Artem Bilan * @author Lukas Gemela + * @author Trung Pham * * @since 4.3 * @@ -246,10 +248,8 @@ protected AbstractFileInfo poll() { private void resetFilterIfNecessary(AbstractFileInfo file) { if (this.filter instanceof ResettableFileListFilter) { - if (this.logger.isInfoEnabled()) { - this.logger.info("Removing the remote file '" + file + - "' from the filter for a subsequent transfer attempt"); - } + this.logger.info(LogMessage.format("Removing the remote file '%s' from" + + "the filterfor a subsequent transfer attempt", file)); ((ResettableFileListFilter) this.filter).remove(file.getFileInfo()); } } diff --git a/spring-integration-http/src/main/java/org/springframework/integration/http/inbound/BaseHttpInboundEndpoint.java b/spring-integration-http/src/main/java/org/springframework/integration/http/inbound/BaseHttpInboundEndpoint.java index b796b1c157f..1498f9bcab3 100644 --- a/spring-integration-http/src/main/java/org/springframework/integration/http/inbound/BaseHttpInboundEndpoint.java +++ b/spring-integration-http/src/main/java/org/springframework/integration/http/inbound/BaseHttpInboundEndpoint.java @@ -51,6 +51,7 @@ * * @author Artem Bilan * @author Gary Russell + * @author Trung Pham * * @since 5.0 */ @@ -284,11 +285,11 @@ protected void onInit() { } private void validateSupportedMethods() { - if (this.requestPayloadType != null && logger.isWarnEnabled() && + if (this.requestPayloadType != null && CollectionUtils.containsAny(NON_READABLE_BODY_HTTP_METHODS, Arrays.asList(getRequestMapping().getMethods()))) { - logger.warn("The 'requestPayloadType' attribute will have no relevance for one " + + logger.warn(() -> "The 'requestPayloadType' attribute will have no relevance for one " + "of the specified HTTP methods '" + NON_READABLE_BODY_HTTP_METHODS + "'"); } } diff --git a/spring-integration-http/src/main/java/org/springframework/integration/http/inbound/HttpRequestHandlingEndpointSupport.java b/spring-integration-http/src/main/java/org/springframework/integration/http/inbound/HttpRequestHandlingEndpointSupport.java index 07e40a03887..aaa902da89c 100644 --- a/spring-integration-http/src/main/java/org/springframework/integration/http/inbound/HttpRequestHandlingEndpointSupport.java +++ b/spring-integration-http/src/main/java/org/springframework/integration/http/inbound/HttpRequestHandlingEndpointSupport.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2021 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. @@ -107,6 +107,7 @@ * @author Gary Russell * @author Artem Bilan * @author Biju Kunjummen + * @author Trung Pham * * @since 2.0 */ @@ -226,17 +227,13 @@ protected void onInit() { try { MultipartResolver resolver = beanFactory.getBean( DispatcherServlet.MULTIPART_RESOLVER_BEAN_NAME, MultipartResolver.class); - if (logger.isDebugEnabled()) { - logger.debug("Using MultipartResolver [" + resolver + "]"); - } + logger.debug(() -> "Using MultipartResolver [" + resolver + "]"); this.multipartResolver = resolver; } catch (NoSuchBeanDefinitionException e) { - if (logger.isDebugEnabled()) { - logger.debug("Unable to locate MultipartResolver with name '" - + DispatcherServlet.MULTIPART_RESOLVER_BEAN_NAME - + "': no multipart request handling will be supported."); - } + logger.debug(() -> "Unable to locate MultipartResolver with name '" + + DispatcherServlet.MULTIPART_RESOLVER_BEAN_NAME + + "': no multipart request handling will be supported."); } } if (this.messageConverters.size() == 0 || (this.mergeWithDefaultConverters && !this.convertersMerged)) { @@ -397,27 +394,21 @@ private StandardEvaluationContext prepareEvaluationContext(HttpServletRequest se (Map) servletRequest.getAttribute(HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE); if (!CollectionUtils.isEmpty(pathVariables)) { - if (logger.isDebugEnabled()) { - logger.debug("Mapped path variables: " + pathVariables); - } + logger.debug(() -> "Mapped path variables: " + pathVariables); evaluationContext.setVariable("pathVariables", pathVariables); } Map matrixVariables = (Map) servletRequest.getAttribute(HandlerMapping.MATRIX_VARIABLES_ATTRIBUTE); if (!CollectionUtils.isEmpty(matrixVariables)) { - if (logger.isDebugEnabled()) { - logger.debug("Mapped matrix variables: " + matrixVariables); - } + logger.debug(() -> "Mapped matrix variables: " + matrixVariables); evaluationContext.setVariable("matrixVariables", matrixVariables); } return evaluationContext; } private Message createServiceUnavailableResponse() { - if (logger.isDebugEnabled()) { - logger.debug("Endpoint is stopped; returning status " + HttpStatus.SERVICE_UNAVAILABLE); - } + logger.debug(() -> "Endpoint is stopped; returning status " + HttpStatus.SERVICE_UNAVAILABLE); return getMessageBuilderFactory() .withPayload("Endpoint is stopped") .setHeader(HttpHeaders.STATUS_CODE, HttpStatus.SERVICE_UNAVAILABLE) diff --git a/spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/connection/AbstractClientConnectionFactory.java b/spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/connection/AbstractClientConnectionFactory.java index d79288ae8db..fc9b876c2df 100644 --- a/spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/connection/AbstractClientConnectionFactory.java +++ b/spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/connection/AbstractClientConnectionFactory.java @@ -34,6 +34,7 @@ * * @author Gary Russell * @author Artem Bilan + * @author Trung Pham * * @since 2.0 * @@ -177,9 +178,7 @@ protected final TcpConnectionSupport obtainNewConnection() throws InterruptedExc private TcpConnectionSupport doObtain(boolean singleUse) { TcpConnectionSupport connection; - if (logger.isDebugEnabled()) { - logger.debug("Opening new socket connection to " + getHost() + ":" + getPort()); - } + logger.debug(() -> "Opening new socket connection to " + getHost() + ":" + getPort()); connection = buildNewConnection(); if (this.connectionTest != null && !this.connectionTest.test(connection)) { diff --git a/spring-integration-jdbc/src/main/java/org/springframework/integration/jdbc/JdbcMessageHandler.java b/spring-integration-jdbc/src/main/java/org/springframework/integration/jdbc/JdbcMessageHandler.java index b77edef0cf9..e9b39d770f9 100644 --- a/spring-integration-jdbc/src/main/java/org/springframework/integration/jdbc/JdbcMessageHandler.java +++ b/spring-integration-jdbc/src/main/java/org/springframework/integration/jdbc/JdbcMessageHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2021 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. @@ -76,6 +76,7 @@ * * @author Dave Syer * @author Artem Bilan + * @author Trung Pham * * @since 2.0 */ @@ -172,8 +173,8 @@ protected void onInit() { @Override protected void handleMessageInternal(Message message) { List> keys = executeUpdateQuery(message, this.keysGenerated); - if (!keys.isEmpty() && logger.isDebugEnabled()) { - logger.debug("Generated keys: " + keys); + if (!keys.isEmpty()) { + logger.debug(() -> "Generated keys: " + keys); } } 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 8d201628f83..f5a172fa8e4 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2021 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. @@ -32,6 +32,7 @@ import org.springframework.beans.factory.InitializingBean; import org.springframework.core.log.LogAccessor; +import org.springframework.core.log.LogMessage; import org.springframework.core.serializer.Deserializer; import org.springframework.core.serializer.Serializer; import org.springframework.core.serializer.support.SerializingConverter; @@ -80,6 +81,7 @@ * @author Artem Bilan * @author Gary Russell * @author Meherzad Lahewala + * @author Trung Pham * * @since 2.2 */ @@ -384,7 +386,7 @@ public void afterPropertiesSet() { this.messageRowMapper = new MessageRowMapper(this.deserializer, this.lobHandler); } - if (this.jdbcTemplate.getFetchSize() != 1 && LOGGER.isWarnEnabled()) { + if (this.jdbcTemplate.getFetchSize() != 1) { LOGGER.warn("The jdbcTemplate's fetch size is not 1. This may cause FIFO issues with Oracle databases."); } @@ -559,7 +561,7 @@ protected Message doPollForMessage(String groupIdKey) { this.idCacheWriteLock.lock(); try { boolean added = this.idCache.add(messageId); - LOGGER.debug(() -> String.format("Polled message with id '%s' added: '%s'.", messageId, added)); + LOGGER.debug(LogMessage.format("Polled message with id '%s' added: '%s'.", messageId, added)); } finally { this.idCacheWriteLock.unlock(); @@ -580,10 +582,10 @@ private boolean doRemoveMessageFromGroup(Object groupId, Message messageToRem boolean result = updated != 0; if (result) { - LOGGER.debug(() -> String.format("Message with id '%s' was deleted.", id)); + LOGGER.debug(LogMessage.format("Message with id '%s' was deleted.", id)); } else { - LOGGER.warn(() -> String.format("Message with id '%s' was not deleted.", id)); + LOGGER.warn(LogMessage.format("Message with id '%s' was not deleted.", id)); } return result; } diff --git a/spring-integration-jmx/src/main/java/org/springframework/integration/jmx/NotificationPublishingMessageHandler.java b/spring-integration-jmx/src/main/java/org/springframework/integration/jmx/NotificationPublishingMessageHandler.java index 6494af2aefd..2480ac21faf 100644 --- a/spring-integration-jmx/src/main/java/org/springframework/integration/jmx/NotificationPublishingMessageHandler.java +++ b/spring-integration-jmx/src/main/java/org/springframework/integration/jmx/NotificationPublishingMessageHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2021 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. @@ -47,6 +47,7 @@ * @author Oleg Zhurakousky * @author Gary Russell * @author Artem Bilan + * @author Trung Pham * * @since 2.0 */ @@ -124,9 +125,7 @@ public final void onInit() { } if (exporter != null) { exporter.registerManagedResource(this.delegate, this.objectName); - if (this.logger.isInfoEnabled()) { - this.logger.info("Registered JMX notification publisher as MBean with ObjectName: " + this.objectName); - } + this.logger.info(() -> "Registered JMX notification publisher as MBean with ObjectName: " + this.objectName); } } diff --git a/spring-integration-jmx/src/main/java/org/springframework/integration/jmx/OperationInvokingMessageHandler.java b/spring-integration-jmx/src/main/java/org/springframework/integration/jmx/OperationInvokingMessageHandler.java index 70bb10ab36d..83e7205d67e 100644 --- a/spring-integration-jmx/src/main/java/org/springframework/integration/jmx/OperationInvokingMessageHandler.java +++ b/spring-integration-jmx/src/main/java/org/springframework/integration/jmx/OperationInvokingMessageHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2021 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. @@ -61,6 +61,7 @@ * @author Oleg Zhurakousky * @author Gary Russell * @author Artem Bilan + * @author Trung Pham * * @since 2.0 */ diff --git a/spring-integration-mail/src/main/java/org/springframework/integration/mail/MailReceivingMessageSource.java b/spring-integration-mail/src/main/java/org/springframework/integration/mail/MailReceivingMessageSource.java index d87f4941ffc..20c85fbb1fa 100644 --- a/spring-integration-mail/src/main/java/org/springframework/integration/mail/MailReceivingMessageSource.java +++ b/spring-integration-mail/src/main/java/org/springframework/integration/mail/MailReceivingMessageSource.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2021 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. @@ -20,6 +20,7 @@ import java.util.Queue; import java.util.concurrent.ConcurrentLinkedQueue; +import org.springframework.core.log.LogMessage; import org.springframework.integration.endpoint.AbstractMessageSource; import org.springframework.messaging.MessagingException; import org.springframework.util.Assert; @@ -34,6 +35,7 @@ * @author Gary Russell * @author Oleg Zhurakousky * @author Artem Bilan + * @author Trung Pham */ public class MailReceivingMessageSource extends AbstractMessageSource { @@ -64,9 +66,7 @@ protected Object doReceive() { mailMessage = this.mailQueue.poll(); } if (mailMessage != null) { - if (this.logger.isDebugEnabled()) { - this.logger.debug("received mail message [" + mailMessage + "]"); - } + this.logger.debug(LogMessage.format("received mail message [%s]", mailMessage)); return mailMessage; } } diff --git a/spring-integration-mqtt/src/main/java/org/springframework/integration/mqtt/inbound/AbstractMqttMessageDrivenChannelAdapter.java b/spring-integration-mqtt/src/main/java/org/springframework/integration/mqtt/inbound/AbstractMqttMessageDrivenChannelAdapter.java index 366b36a21d4..487b29bfb1c 100644 --- a/spring-integration-mqtt/src/main/java/org/springframework/integration/mqtt/inbound/AbstractMqttMessageDrivenChannelAdapter.java +++ b/spring-integration-mqtt/src/main/java/org/springframework/integration/mqtt/inbound/AbstractMqttMessageDrivenChannelAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2021 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. @@ -21,6 +21,7 @@ import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; +import org.springframework.core.log.LogMessage; import org.springframework.integration.endpoint.MessageProducerSupport; import org.springframework.integration.mqtt.support.DefaultPahoMessageConverter; import org.springframework.integration.mqtt.support.MqttMessageConverter; @@ -37,6 +38,7 @@ * * @author Gary Russell * @author Artem Bilan + * @author Trung Pham * * @since 4.0 * @@ -161,9 +163,7 @@ public void addTopic(String topic, int qos) { throw new MessagingException("Topic '" + topic + "' is already subscribed."); } this.topics.add(topik); - if (this.logger.isDebugEnabled()) { - logger.debug("Added '" + topic + "' to subscriptions."); - } + logger.debug(LogMessage.format("Added '%s' to subscriptions.", topic)); } finally { this.topicLock.unlock(); @@ -229,8 +229,8 @@ public void removeTopic(String... topic) { this.topicLock.lock(); try { for (String t : topic) { - if (this.topics.remove(new Topic(t, 0)) && this.logger.isDebugEnabled()) { - logger.debug("Removed '" + t + "' from subscriptions."); + if (this.topics.remove(new Topic(t, 0))) { + logger.debug(LogMessage.format("Removed '%s' from subscriptions.", t)); } } } diff --git a/spring-integration-redis/src/main/java/org/springframework/integration/redis/outbound/RedisStoreWritingMessageHandler.java b/spring-integration-redis/src/main/java/org/springframework/integration/redis/outbound/RedisStoreWritingMessageHandler.java index 40a26391e4d..77a15d1904a 100644 --- a/spring-integration-redis/src/main/java/org/springframework/integration/redis/outbound/RedisStoreWritingMessageHandler.java +++ b/spring-integration-redis/src/main/java/org/springframework/integration/redis/outbound/RedisStoreWritingMessageHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2007-2019 the original author or authors. + * Copyright 2007-2021 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. @@ -21,6 +21,7 @@ import java.util.Map.Entry; import java.util.Properties; +import org.springframework.core.log.LogMessage; import org.springframework.data.redis.connection.RedisConnection; import org.springframework.data.redis.connection.RedisConnectionFactory; import org.springframework.data.redis.core.BoundSetOperations; @@ -68,6 +69,7 @@ * @author Gary Russell * @author Mark Fisher * @author Artem Bilan + * @author Trung Pham * * @since 2.2 */ @@ -464,10 +466,8 @@ private void doIncrementOrOverwrite(BoundZSetOperations ops, Obj private boolean verifyAllMapValuesOfTypeNumber(Map map) { for (Object value : map.values()) { if (!(value instanceof Number)) { - if (this.logger.isWarnEnabled()) { - this.logger.warn("failed to extract payload elements because '" + - value + "' is not of type Number"); - } + this.logger.warn(LogMessage.format("failed to extract payload elements" + + "because '%s' is not of type Number", value)); return false; } } diff --git a/spring-integration-stomp/src/main/java/org/springframework/integration/stomp/inbound/StompInboundChannelAdapter.java b/spring-integration-stomp/src/main/java/org/springframework/integration/stomp/inbound/StompInboundChannelAdapter.java index 4b5ecf411f4..84b34096dee 100644 --- a/spring-integration-stomp/src/main/java/org/springframework/integration/stomp/inbound/StompInboundChannelAdapter.java +++ b/spring-integration-stomp/src/main/java/org/springframework/integration/stomp/inbound/StompInboundChannelAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2020 the original author or authors. + * Copyright 2015-2021 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. @@ -28,6 +28,7 @@ import org.springframework.context.ApplicationEventPublisher; import org.springframework.context.ApplicationEventPublisherAware; import org.springframework.context.Lifecycle; +import org.springframework.core.log.LogMessage; import org.springframework.integration.endpoint.MessageProducerSupport; import org.springframework.integration.mapping.HeaderMapper; import org.springframework.integration.stomp.StompSessionManager; @@ -63,6 +64,7 @@ * * @author Artem Bilan * @author Gary Russell + * @author Trung Pham * * @since 4.2 */ @@ -137,9 +139,7 @@ public void addDestination(String... destination) { Arrays.stream(destination) .filter(this.destinations::add) .forEach(d -> { - if (this.logger.isDebugEnabled()) { - logger.debug("Subscribe to destination '" + d + "'."); - } + logger.debug(LogMessage.format("Subscribe to destination '%s'.", d)); subscribeDestination(d); }); } @@ -160,17 +160,13 @@ public void removeDestination(String... destination) { Arrays.stream(destination) .filter(this.destinations::remove) .forEach(d -> { - if (this.logger.isDebugEnabled()) { - logger.debug("Removed '" + d + "' from subscriptions."); - } + logger.debug(LogMessage.format("Removed '%s' from subscriptions.", d)); StompSession.Subscription subscription = this.subscriptions.get(d); if (subscription != null) { subscription.unsubscribe(); } else { - if (this.logger.isDebugEnabled()) { - logger.debug("No subscription for destination '" + d + "'."); - } + logger.debug(LogMessage.format("No subscription for destination '%s'.", d)); } }); } @@ -257,15 +253,15 @@ else if (body instanceof Message) { eventPublisher.publishEvent(event); } else { - logger.error("The receipt [" + subscription.getReceiptId() + "] is lost for [" + + logger.error(() -> "The receipt [" + subscription.getReceiptId() + "] is lost for [" + subscription.getSubscriptionId() + "] on destination [" + destination + "]"); } }); } this.subscriptions.put(destination, subscription); } - else if (logger.isWarnEnabled()) { - logger.warn("The StompInboundChannelAdapter [" + getComponentName() + + else { + logger.warn(() -> "The StompInboundChannelAdapter [" + getComponentName() + "] ins't connected to StompSession. Check the state of [" + this.stompSessionManager + "]"); } } diff --git a/spring-integration-xml/src/main/java/org/springframework/integration/xml/transformer/XsltPayloadTransformer.java b/spring-integration-xml/src/main/java/org/springframework/integration/xml/transformer/XsltPayloadTransformer.java index 39741885fb8..e0223e2fc71 100644 --- a/spring-integration-xml/src/main/java/org/springframework/integration/xml/transformer/XsltPayloadTransformer.java +++ b/spring-integration-xml/src/main/java/org/springframework/integration/xml/transformer/XsltPayloadTransformer.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2021 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. @@ -84,6 +84,7 @@ * @author Artem Bilan * @author Mike Bazos * @author Gary Russell + * @author Trung Pham */ public class XsltPayloadTransformer extends AbstractXmlTransformer implements BeanClassLoaderAware { @@ -270,10 +271,8 @@ private TransformerFactory createTransformerFactory() throws ClassNotFoundExcept transformerFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_STYLESHEET, "file,jar:file"); } catch (@SuppressWarnings("unused") IllegalArgumentException ex) { - if (logger.isInfoEnabled()) { - logger.info("The '" + XMLConstants.ACCESS_EXTERNAL_STYLESHEET + "' property is not supported by " - + transformerFactory.getClass().getCanonicalName()); - } + logger.info(() -> "The '" + XMLConstants.ACCESS_EXTERNAL_STYLESHEET + "' property is not supported by " + + transformerFactory.getClass().getCanonicalName()); } return transformerFactory; } @@ -395,12 +394,10 @@ private Transformer buildTransformer(Message message) throws TransformerExcep transformer.setParameter(parameterName, value); } catch (Exception e) { - if (logger.isWarnEnabled()) { - logger.warn("Evaluation of header expression '" - + expression.getExpressionString() - + "' failed. The XSLT parameter '" - + parameterName + "' will be skipped."); - } + logger.warn(() -> "Evaluation of header expression '" + + expression.getExpressionString() + + "' failed. The XSLT parameter '" + + parameterName + "' will be skipped."); } } } diff --git a/spring-integration-xmpp/src/main/java/org/springframework/integration/xmpp/inbound/PresenceListeningEndpoint.java b/spring-integration-xmpp/src/main/java/org/springframework/integration/xmpp/inbound/PresenceListeningEndpoint.java index 7317976104d..dcab2c4f44f 100644 --- a/spring-integration-xmpp/src/main/java/org/springframework/integration/xmpp/inbound/PresenceListeningEndpoint.java +++ b/spring-integration-xmpp/src/main/java/org/springframework/integration/xmpp/inbound/PresenceListeningEndpoint.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2021 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. @@ -38,6 +38,7 @@ * @author Mark Fisher * @author Artem Bilan * @author Gary Russell + * @author Trung Pham * * @since 2.0 */ @@ -87,31 +88,23 @@ private class PresencePublishingRosterListener implements RosterListener { @Override public void entriesAdded(Collection entries) { - if (logger.isDebugEnabled()) { - logger.debug("entries added: " + StringUtils.collectionToCommaDelimitedString(entries)); - } + logger.debug(() -> "entries added: " + StringUtils.collectionToCommaDelimitedString(entries)); } @Override public void entriesUpdated(Collection entries) { - if (logger.isDebugEnabled()) { - logger.debug("entries updated: " + StringUtils.collectionToCommaDelimitedString(entries)); - } + logger.debug(() -> "entries updated: " + StringUtils.collectionToCommaDelimitedString(entries)); } @Override public void entriesDeleted(Collection entries) { - if (logger.isDebugEnabled()) { - logger.debug("entries deleted: " + StringUtils.collectionToCommaDelimitedString(entries)); - } + logger.debug(() -> "entries deleted: " + StringUtils.collectionToCommaDelimitedString(entries)); } @Override public void presenceChanged(Presence presence) { if (presence != null) { - if (logger.isDebugEnabled()) { - logger.debug("presence changed: " + presence.getFrom() + " - " + presence); - } + logger.debug(() -> "presence changed: " + presence.getFrom() + " - " + presence); sendMessage(PresenceListeningEndpoint.this.getMessageBuilderFactory().withPayload(presence).build()); } }