Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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;
Expand Down Expand Up @@ -47,6 +48,7 @@
* @author Oleg Zhurakousky
* @author Gary Russell
* @author Artem Bilan
* @author Trung Pham
*
* @see AbstractCorrelatingMessageHandler
*/
Expand Down Expand Up @@ -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) {
Expand All @@ -119,9 +119,7 @@ public Message<Object> 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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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;
Expand All @@ -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 {
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -43,6 +43,7 @@
*
* @author Gary Russell
* @author Artem Bilan
* @author Trung Pham
*
* @since 3.0
*
Expand Down Expand Up @@ -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 {
Expand All @@ -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();
Expand All @@ -211,27 +210,21 @@ 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<Entry<String, MessageChannelWrapper>> iterator = this.channels.entrySet().iterator();
long now = System.currentTimeMillis();
while (iterator.hasNext()) {
Entry<String, MessageChannelWrapper> 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();
}
}
this.reaperScheduledFuture =
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());
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
* @author Oleg Zhurakousky
* @author Gary Russell
* @author Artem Bilan
* @author Trung Pham
*/
public class PublishSubscribeChannel extends AbstractExecutorChannel implements BroadcastCapableChannel {

Expand Down Expand Up @@ -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");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
* @author Kris Jacyna
* @author Gary Russell
* @author Artem Bilan
* @author Trung Pham
*/
@IntegrationManagedResource
public abstract class AbstractEndpoint extends IntegrationObjectSupport
Expand Down Expand Up @@ -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 {
Expand All @@ -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 {
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
* input channel and reactive consumption of messages from that channel.
*
* @author Artem Bilan
* @author Trung Pham
*
* @since 5.0
*/
Expand Down Expand Up @@ -89,7 +90,7 @@ public ReactiveStreamsConsumer(MessageChannel inputChannel, Subscriber<Message<?
Assert.notNull(subscriber, "'subscriber' must not be null");
this.inputChannel = inputChannel;

if (inputChannel instanceof NullChannel && logger.isWarnEnabled()) {
if (inputChannel instanceof NullChannel) {
logger.warn("The consuming from the NullChannel does not have any effects: " +
"it doesn't forward messages sent to it. A NullChannel is the end of the flow.");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -78,6 +78,7 @@
* @author Mark Fisher
* @author Gary Russell
* @author Artem Bilan
* @author Trung Pham
*/
@IntegrationManagedResource
public abstract class MessagingGatewaySupport extends AbstractEndpoint
Expand Down Expand Up @@ -529,9 +530,7 @@ private Object doSendAndReceive(Object object, boolean shouldConvert) {
}
}
catch (Throwable ex) { // NOSONAR (catch throwable)
if (logger.isDebugEnabled()) {
logger.debug("failure occurred in gateway sendAndReceive: " + ex.getMessage());
}
logger.debug(() -> "failure occurred in gateway sendAndReceive: " + ex.getMessage());
reply = ex;
if (sample != null) {
sample.stop(buildSendTimer(false, ex.getClass().getSimpleName()));
Expand Down Expand Up @@ -708,9 +707,7 @@ private Mono<Message<?>> buildReplyMono(Message<?> requestMessage, Mono<Message<
}

private Mono<Message<?>> 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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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;
Expand All @@ -28,6 +29,7 @@
*
* @author David Turanski
* @author Artem Bilan
* @author Trung Pham
*
* @since 5.3
*/
Expand All @@ -37,8 +39,8 @@ public abstract class AbstractReactiveMessageHandler extends MessageHandlerSuppo
@Override
public Mono<Void> 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;
Expand All @@ -49,8 +51,8 @@ public Mono<Void> 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<Void> handleMessageInternal(Message<?> message);
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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;
Expand All @@ -39,6 +40,7 @@
* @author Gary Russell
* @author Artem Bilan
* @author David Liu
* @author Trung Pham
*/
public abstract class AbstractReplyProducingMessageHandler extends AbstractMessageProducingHandler
implements BeanClassLoaderAware {
Expand Down Expand Up @@ -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));
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -65,6 +65,7 @@
* @author Iwein Fuld
* @author Gary Russell
* @author Artem Bilan
* @author Trung Pham
*/
public class MessageHandlerChain extends AbstractMessageProducingHandler
implements CompositeMessageHandler, ManageableLifecycle {
Expand Down Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down
Loading