diff --git a/spring-integration-core/src/main/java/org/springframework/integration/config/AbstractMethodAnnotationPostProcessor.java b/spring-integration-core/src/main/java/org/springframework/integration/config/AbstractMethodAnnotationPostProcessor.java index 239f2330b8..69457aa69b 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/config/AbstractMethodAnnotationPostProcessor.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/config/AbstractMethodAnnotationPostProcessor.java @@ -187,12 +187,15 @@ public abstract class AbstractMethodAnnotationPostProcessor handlerBeanClass = - org.springframework.util.ClassUtils.resolveClassName(handlerBeanDefinition.getBeanClassName(), + org.springframework.util.ClassUtils.resolveClassName(beanClassName, this.beanFactory.getBeanClassLoader()); if (isClassIn(handlerBeanClass, Orderable.class, AbstractSimpleMessageHandlerFactoryBean.class)) { @@ -381,6 +384,7 @@ public abstract class AbstractMethodAnnotationPostProcessor beanClass = org.springframework.util.ClassUtils.resolveClassName(typeName, diff --git a/spring-integration-core/src/main/java/org/springframework/integration/context/IntegrationContextUtils.java b/spring-integration-core/src/main/java/org/springframework/integration/context/IntegrationContextUtils.java index 3b3e34de3e..7d82d35b7c 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/context/IntegrationContextUtils.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/context/IntegrationContextUtils.java @@ -16,9 +16,6 @@ package org.springframework.integration.context; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.NoSuchBeanDefinitionException; import org.springframework.beans.factory.config.BeanDefinition; @@ -90,8 +87,6 @@ public abstract class IntegrationContextUtils { public static final String GLOBAL_CHANNEL_INTERCEPTOR_PROCESSOR_BEAN_NAME = "globalChannelInterceptorProcessor"; - public static final String JSON_NODE_WRAPPER_TO_JSON_NODE_CONVERTER = "jsonNodeWrapperToJsonNodeConverter"; - public static final String INTEGRATION_LIFECYCLE_ROLE_CONTROLLER = "integrationLifecycleRoleController"; public static final String INTEGRATION_GRAPH_SERVER_BEAN_NAME = "integrationGraphServer"; @@ -106,8 +101,6 @@ public abstract class IntegrationContextUtils { public static final String LIST_MESSAGE_HANDLER_FACTORY_BEAN_NAME = "integrationListMessageHandlerMethodFactory"; - private static final Log LOGGER = LogFactory.getLog(IntegrationContextUtils.class); - /** * @param beanFactory BeanFactory for lookup, must not be null. * @return The {@link MetadataStore} bean whose name is "metadataStore". diff --git a/spring-integration-core/src/main/java/org/springframework/integration/dispatcher/AggregateMessageDeliveryException.java b/spring-integration-core/src/main/java/org/springframework/integration/dispatcher/AggregateMessageDeliveryException.java index 4af159f6f3..09187307b2 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/dispatcher/AggregateMessageDeliveryException.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/dispatcher/AggregateMessageDeliveryException.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2022 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,7 +61,9 @@ public class AggregateMessageDeliveryException extends MessageDeliveryException StringBuilder message = new StringBuilder(appendPeriodIfNecessary(baseMessage)) .append(" Multiple causes:\n"); for (Exception exception : this.aggregatedExceptions) { - message.append(" " + exception.getMessage() + "\n"); + message.append(" ") + .append(exception.getMessage()) + .append("\n"); } message.append("See below for the stacktrace of the first cause."); return message.toString(); diff --git a/spring-integration-core/src/main/java/org/springframework/integration/dsl/Pollers.java b/spring-integration-core/src/main/java/org/springframework/integration/dsl/Pollers.java index a1e5ffd03a..6c8c863e3e 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/dsl/Pollers.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/dsl/Pollers.java @@ -53,7 +53,7 @@ public final class Pollers { /** * @deprecated since 6.0 in favor of {@link #fixedRate(Duration)} */ - @Deprecated(since = "6.0", forRemoval = true) + @Deprecated(forRemoval = true) public static PollerSpec fixedRate(long period, TimeUnit timeUnit) { return fixedRate(Duration.of(period, timeUnit.toChronoUnit())); } @@ -69,7 +69,7 @@ public final class Pollers { /** * @deprecated since 6.0 in favor of {@link #fixedRate(Duration, Duration)} */ - @Deprecated(since = "6.0", forRemoval = true) + @Deprecated(forRemoval = true) public static PollerSpec fixedRate(long period, TimeUnit timeUnit, long initialDelay) { ChronoUnit chronoUnit = timeUnit.toChronoUnit(); return fixedRate(Duration.of(period, chronoUnit), Duration.of(initialDelay, chronoUnit)); @@ -90,7 +90,7 @@ public final class Pollers { /** * @deprecated since 6.0 in favor of {@link #fixedDelay(Duration)} */ - @Deprecated(since = "6.0", forRemoval = true) + @Deprecated(forRemoval = true) public static PollerSpec fixedDelay(long period, TimeUnit timeUnit) { return fixedDelay(Duration.of(period, timeUnit.toChronoUnit())); } @@ -102,7 +102,7 @@ public final class Pollers { /** * @deprecated since 6.0 in favor of {@link #fixedDelay(Duration, Duration)} */ - @Deprecated(since = "6.0", forRemoval = true) + @Deprecated(forRemoval = true) public static PollerSpec fixedDelay(long period, TimeUnit timeUnit, long initialDelay) { ChronoUnit chronoUnit = timeUnit.toChronoUnit(); return fixedDelay(Duration.of(period, chronoUnit), Duration.of(initialDelay, chronoUnit)); diff --git a/spring-integration-core/src/main/java/org/springframework/integration/gateway/DefaultMethodInvokingMethodInterceptor.java b/spring-integration-core/src/main/java/org/springframework/integration/gateway/DefaultMethodInvokingMethodInterceptor.java index 72555af44a..0dd7790f89 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/gateway/DefaultMethodInvokingMethodInterceptor.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/gateway/DefaultMethodInvokingMethodInterceptor.java @@ -36,7 +36,7 @@ import org.springframework.util.ReflectionUtils; /** * Method interceptor to invoke default methods on the gateway proxy. - * + *

* The copy of {@code DefaultMethodInvokingMethodInterceptor} from Spring Data Commons. * * @author Oliver Gierke @@ -122,7 +122,7 @@ class DefaultMethodInvokingMethodInterceptor implements MethodInterceptor { private volatile boolean constructorResolved; - private Constructor constructor; + private transient Constructor constructor; private final Supplier> constructorSupplier = () -> { diff --git a/spring-integration-core/src/main/java/org/springframework/integration/handler/LambdaMessageProcessor.java b/spring-integration-core/src/main/java/org/springframework/integration/handler/LambdaMessageProcessor.java index beb2ac353a..a5dcc95e9e 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/handler/LambdaMessageProcessor.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/handler/LambdaMessageProcessor.java @@ -122,10 +122,11 @@ public class LambdaMessageProcessor implements MessageProcessor, BeanFac } return result; } + catch (ClassCastException ex) { + logClassCastException(ex); + throw ex; + } catch (RuntimeException ex) { - if (ex instanceof ClassCastException classCastException) { - logClassCastException(classCastException); - } throw ex; } catch (InvocationTargetException e) { 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 07d106c833..7628d1961b 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 @@ -1013,13 +1013,6 @@ public class MessagingMethodInvokerHelper extends AbstractExpressionEvaluator im return null; } - private static boolean isMethodDefinedOnObjectClass(Method method) { - return method != null && // NOSONAR - (ReflectionUtils.isObjectMethod(method) || - AopUtils.isFinalizeMethod(method) || (method.getName().equals("clone") - && method.getParameterTypes().length == 0)); - } - public boolean isAsync() { if (this.handlerMethodsList.size() == 1) { Method methodToCheck = this.handlerMethodsList.get(0).values().iterator().next().method; diff --git a/spring-integration-groovy/src/main/java/org/springframework/integration/groovy/GroovyScriptExecutingMessageProcessor.java b/spring-integration-groovy/src/main/java/org/springframework/integration/groovy/GroovyScriptExecutingMessageProcessor.java index c5b176a36b..4164e21031 100644 --- a/spring-integration-groovy/src/main/java/org/springframework/integration/groovy/GroovyScriptExecutingMessageProcessor.java +++ b/spring-integration-groovy/src/main/java/org/springframework/integration/groovy/GroovyScriptExecutingMessageProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2021 the original author or authors. + * Copyright 2002-2022 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. @@ -70,7 +70,7 @@ public class GroovyScriptExecutingMessageProcessor extends AbstractScriptExecuti private final Lock scriptLock = new ReentrantLock(); - private ScriptSource scriptSource; + private final ScriptSource scriptSource; private GroovyClassLoader groovyClassLoader = new GroovyClassLoader(ClassUtils.getDefaultClassLoader()); diff --git a/spring-integration-hazelcast/src/main/java/org/springframework/integration/hazelcast/HazelcastLocalInstanceRegistrar.java b/spring-integration-hazelcast/src/main/java/org/springframework/integration/hazelcast/HazelcastLocalInstanceRegistrar.java index 8ead3df839..c7f038fc25 100644 --- a/spring-integration-hazelcast/src/main/java/org/springframework/integration/hazelcast/HazelcastLocalInstanceRegistrar.java +++ b/spring-integration-hazelcast/src/main/java/org/springframework/integration/hazelcast/HazelcastLocalInstanceRegistrar.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2019 the original author or authors. + * Copyright 2015-2022 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. @@ -82,9 +82,9 @@ public class HazelcastLocalInstanceRegistrar implements SmartInitializingSinglet public void afterSingletonsInstantiated() { if (this.hazelcastInstance == null) { if (!Hazelcast.getAllHazelcastInstances().isEmpty()) { - HazelcastInstance hazelcastInstance = Hazelcast.getAllHazelcastInstances().iterator().next(); - hazelcastInstance.getCluster().addMembershipListener(new HazelcastMembershipListener()); - syncConfigurationMultiMap(hazelcastInstance); + HazelcastInstance anyHazelcastInstance = Hazelcast.getAllHazelcastInstances().iterator().next(); + anyHazelcastInstance.getCluster().addMembershipListener(new HazelcastMembershipListener()); + syncConfigurationMultiMap(anyHazelcastInstance); } else { logger.warn("No HazelcastInstances for MembershipListener registration"); diff --git a/spring-integration-hazelcast/src/main/java/org/springframework/integration/hazelcast/inbound/AbstractHazelcastMessageProducer.java b/spring-integration-hazelcast/src/main/java/org/springframework/integration/hazelcast/inbound/AbstractHazelcastMessageProducer.java index 7a749a9f2a..b6a3307f88 100644 --- a/spring-integration-hazelcast/src/main/java/org/springframework/integration/hazelcast/inbound/AbstractHazelcastMessageProducer.java +++ b/spring-integration-hazelcast/src/main/java/org/springframework/integration/hazelcast/inbound/AbstractHazelcastMessageProducer.java @@ -73,12 +73,12 @@ public abstract class AbstractHazelcastMessageProducer extends MessageProducerSu } public void setCacheEventTypes(String cacheEventTypes) { - Set cacheEvents = + Set events = HazelcastIntegrationDefinitionValidator.validateEnumType(CacheEventType.class, cacheEventTypes); - Assert.notEmpty(cacheEvents, "'cacheEvents' must have elements"); + Assert.notEmpty(events, "'events' must have elements"); HazelcastIntegrationDefinitionValidator.validateCacheEventsByDistributedObject(this.distributedObject, - cacheEvents); - this.cacheEvents = cacheEvents; + events); + this.cacheEvents = events; } protected CacheListeningPolicyType getCacheListeningPolicy() { diff --git a/spring-integration-hazelcast/src/main/java/org/springframework/integration/hazelcast/metadata/HazelcastMetadataStore.java b/spring-integration-hazelcast/src/main/java/org/springframework/integration/hazelcast/metadata/HazelcastMetadataStore.java index 2b2fe919ab..68444916a2 100644 --- a/spring-integration-hazelcast/src/main/java/org/springframework/integration/hazelcast/metadata/HazelcastMetadataStore.java +++ b/spring-integration-hazelcast/src/main/java/org/springframework/integration/hazelcast/metadata/HazelcastMetadataStore.java @@ -1,5 +1,5 @@ /* - * Copyright 2017 the original author or authors. + * Copyright 2017-2022 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,7 +43,7 @@ public class HazelcastMetadataStore implements ListenableMetadataStore, Initiali private final IMap map; - private final List listeners = new CopyOnWriteArrayList(); + private final List listeners = new CopyOnWriteArrayList<>(); public HazelcastMetadataStore(HazelcastInstance hazelcastInstance) { Assert.notNull(hazelcastInstance, "Hazelcast instance can't be null"); @@ -57,14 +57,14 @@ public class HazelcastMetadataStore implements ListenableMetadataStore, Initiali @Override public String putIfAbsent(String key, String value) { - Assert.notNull(key, "'key' must not be null."); + assertKey(key); Assert.notNull(value, "'value' must not be null."); return this.map.putIfAbsent(key, value); } @Override public boolean replace(String key, String oldValue, String newValue) { - Assert.notNull(key, "'key' must not be null."); + assertKey(key); Assert.notNull(oldValue, "'oldValue' must not be null."); Assert.notNull(newValue, "'newValue' must not be null."); return this.map.replace(key, oldValue, newValue); @@ -72,23 +72,27 @@ public class HazelcastMetadataStore implements ListenableMetadataStore, Initiali @Override public void put(String key, String value) { - Assert.notNull(key, "'key' must not be null."); + assertKey(key); Assert.notNull(value, "'value' must not be null."); this.map.put(key, value); } @Override public String get(String key) { - Assert.notNull(key, "'key' must not be null."); + assertKey(key); return this.map.get(key); } @Override public String remove(String key) { - Assert.notNull(key, "'key' must not be null."); + assertKey(key); return this.map.remove(key); } + private static void assertKey(String key) { + Assert.notNull(key, "'key' must not be null."); + } + @Override public void addListener(MetadataStoreListener callback) { Assert.notNull(callback, "callback object can not be null"); @@ -101,18 +105,14 @@ public class HazelcastMetadataStore implements ListenableMetadataStore, Initiali } @Override - public void afterPropertiesSet() throws Exception { + public void afterPropertiesSet() { this.map.addEntryListener(new MapListener(this.listeners), true); } - private static class MapListener implements EntryAddedListener, - EntryRemovedListener, EntryUpdatedListener { - - private final List listeners; - - MapListener(List listeners) { - this.listeners = listeners; - } + private record MapListener(List listeners) + implements EntryAddedListener, + EntryRemovedListener, + EntryUpdatedListener { @Override public void entryAdded(EntryEvent event) { diff --git a/spring-integration-jdbc/src/main/java/org/springframework/integration/jdbc/channel/PostgresChannelMessageTableSubscriber.java b/spring-integration-jdbc/src/main/java/org/springframework/integration/jdbc/channel/PostgresChannelMessageTableSubscriber.java index e6ad7c6ca2..a02c1a1485 100644 --- a/spring-integration-jdbc/src/main/java/org/springframework/integration/jdbc/channel/PostgresChannelMessageTableSubscriber.java +++ b/spring-integration-jdbc/src/main/java/org/springframework/integration/jdbc/channel/PostgresChannelMessageTableSubscriber.java @@ -66,7 +66,7 @@ public final class PostgresChannelMessageTableSubscriber implements SmartLifecyc private static final LogAccessor LOGGER = new LogAccessor(PostgresChannelMessageTableSubscriber.class); - private final Map> subscriptions = new ConcurrentHashMap<>(); + private final Map> subscriptionsMap = new ConcurrentHashMap<>(); private final PgConnectionSupplier connectionSupplier; @@ -120,7 +120,7 @@ public final class PostgresChannelMessageTableSubscriber implements SmartLifecyc public boolean subscribe(Subscription subscription) { String subscriptionKey = subscription.getRegion() + " " + getKey(subscription.getGroupId()); Set subscriptions = - this.subscriptions.computeIfAbsent(subscriptionKey, __ -> ConcurrentHashMap.newKeySet()); + this.subscriptionsMap.computeIfAbsent(subscriptionKey, __ -> ConcurrentHashMap.newKeySet()); return subscriptions.add(subscription); } @@ -131,7 +131,7 @@ public final class PostgresChannelMessageTableSubscriber implements SmartLifecyc */ public boolean unsubscribe(Subscription subscription) { String subscriptionKey = subscription.getRegion() + " " + getKey(subscription.getGroupId()); - Set subscriptions = this.subscriptions.get(subscriptionKey); + Set subscriptions = this.subscriptionsMap.get(subscriptionKey); return subscriptions != null && subscriptions.remove(subscription); } @@ -140,16 +140,16 @@ public final class PostgresChannelMessageTableSubscriber implements SmartLifecyc if (this.latch.getCount() > 0) { return; } - ExecutorService executor = this.executor; - if (executor == null) { + ExecutorService executorToUse = this.executor; + if (executorToUse == null) { CustomizableThreadFactory threadFactory = new CustomizableThreadFactory("postgres-channel-message-table-subscriber-"); threadFactory.setDaemon(true); - executor = Executors.newSingleThreadExecutor(threadFactory); - this.executor = executor; + executorToUse = Executors.newSingleThreadExecutor(threadFactory); + this.executor = executorToUse; } this.latch = new CountDownLatch(1); - this.future = executor.submit(() -> { + this.future = executorToUse.submit(() -> { try { while (isActive()) { try { @@ -157,16 +157,16 @@ public final class PostgresChannelMessageTableSubscriber implements SmartLifecyc try (Statement stmt = conn.createStatement()) { stmt.execute("LISTEN " + this.tablePrefix.toLowerCase() + "channel_message_notify"); } - catch (Throwable t) { + catch (Exception ex) { try { conn.close(); } - catch (Throwable suppressed) { - t.addSuppressed(suppressed); + catch (Exception suppressed) { + ex.addSuppressed(suppressed); } - throw t; + throw ex; } - this.subscriptions.values() + this.subscriptionsMap.values() .forEach(subscriptions -> subscriptions.forEach(Subscription::notifyUpdate)); try { this.connection = conn; @@ -180,7 +180,7 @@ public final class PostgresChannelMessageTableSubscriber implements SmartLifecyc if (notifications != null) { for (PGNotification notification : notifications) { String parameter = notification.getParameter(); - Set subscriptions = this.subscriptions.get(parameter); + Set subscriptions = this.subscriptionsMap.get(parameter); if (subscriptions == null) { continue; } @@ -202,10 +202,6 @@ public final class PostgresChannelMessageTableSubscriber implements SmartLifecyc LOGGER.error(e, "Failed to poll notifications from Postgres database"); } } - catch (Throwable t) { - LOGGER.error(t, "Failed to poll notifications from Postgres database"); - return; - } } } finally { @@ -224,11 +220,10 @@ public final class PostgresChannelMessageTableSubscriber implements SmartLifecyc @Override public synchronized void stop() { - Future future = this.future; - if (future.isDone()) { + if (this.future.isDone()) { return; } - future.cancel(true); + this.future.cancel(true); PgConnection conn = this.connection; if (conn != null) { try { diff --git a/spring-integration-jdbc/src/main/java/org/springframework/integration/jdbc/store/JdbcMessageStore.java b/spring-integration-jdbc/src/main/java/org/springframework/integration/jdbc/store/JdbcMessageStore.java index 10c04fbb42..83229008b0 100644 --- a/spring-integration-jdbc/src/main/java/org/springframework/integration/jdbc/store/JdbcMessageStore.java +++ b/spring-integration-jdbc/src/main/java/org/springframework/integration/jdbc/store/JdbcMessageStore.java @@ -16,7 +16,6 @@ package org.springframework.integration.jdbc.store; -import java.sql.DatabaseMetaData; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Timestamp; @@ -50,9 +49,6 @@ import org.springframework.jdbc.core.JdbcOperations; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.RowMapper; import org.springframework.jdbc.core.SingleColumnRowMapper; -import org.springframework.jdbc.support.JdbcAccessor; -import org.springframework.jdbc.support.JdbcUtils; -import org.springframework.jdbc.support.MetaDataAccessException; import org.springframework.jdbc.support.lob.DefaultLobHandler; import org.springframework.jdbc.support.lob.LobHandler; import org.springframework.jmx.export.annotation.ManagedAttribute; @@ -171,8 +167,6 @@ public class JdbcMessageStore extends AbstractMessageGroupStore implements Messa private final JdbcOperations jdbcTemplate; - private final String vendorName; - private final Map queryCache = new ConcurrentHashMap<>(); private String region = "DEFAULT"; @@ -205,14 +199,6 @@ public class JdbcMessageStore extends AbstractMessageGroupStore implements Messa Assert.notNull(jdbcOperations, "'dataSource' must not be null"); this.jdbcTemplate = jdbcOperations; this.serializer = new SerializingConverter(); - try { - this.vendorName = - JdbcUtils.extractDatabaseMetaData(((JdbcAccessor) jdbcOperations).getDataSource(), // NOSONAR - DatabaseMetaData::getDatabaseProductName); - } - catch (MetaDataAccessException ex) { - throw new IllegalStateException("Cannot extract database vendor name", ex); - } } @Override diff --git a/spring-integration-sftp/src/main/java/org/springframework/integration/sftp/session/SftpSession.java b/spring-integration-sftp/src/main/java/org/springframework/integration/sftp/session/SftpSession.java index 0942800455..40e87ac710 100644 --- a/spring-integration-sftp/src/main/java/org/springframework/integration/sftp/session/SftpSession.java +++ b/spring-integration-sftp/src/main/java/org/springframework/integration/sftp/session/SftpSession.java @@ -171,12 +171,15 @@ public class SftpSession implements Session { this.sftpClient.lstat(path); return true; } - catch (IOException ex) { - if (ex instanceof SftpException sftpException && - SftpConstants.SSH_FX_NO_SUCH_FILE == sftpException.getStatus()) { - + catch (SftpException ex) { + if (SftpConstants.SSH_FX_NO_SUCH_FILE == ex.getStatus()) { return false; } + else { + throw new UncheckedIOException("Cannot check 'lstat' for path " + path, ex); + } + } + catch (IOException ex) { throw new UncheckedIOException("Cannot check 'lstat' for path " + path, ex); } } diff --git a/spring-integration-test-support/src/main/java/org/springframework/integration/test/util/TestUtils.java b/spring-integration-test-support/src/main/java/org/springframework/integration/test/util/TestUtils.java index e21ecac45c..5e86082e3a 100644 --- a/spring-integration-test-support/src/main/java/org/springframework/integration/test/util/TestUtils.java +++ b/spring-integration-test-support/src/main/java/org/springframework/integration/test/util/TestUtils.java @@ -257,12 +257,13 @@ public abstract class TestUtils { try { sent = errorChannel.send(new ErrorMessage(throwable), 10000); // NOSONAR } - catch (Throwable errorDeliveryError) { // NOSONAR + catch (Exception deliveryException) { // message will be logged only - logger.warn("Error message was not delivered.", errorDeliveryError); - if (errorDeliveryError instanceof Error) { // NOSONAR - throw (Error) errorDeliveryError; - } + logger.warn("Error message was not delivered.", deliveryException); + } + catch (Error deliveryError) { + logger.warn("Error message was not delivered.", deliveryError); + throw deliveryError; } } if (!sent && logger.isErrorEnabled()) {