From 498f42d4803ccd6b03bcc0896921e3d28f2d3b4c Mon Sep 17 00:00:00 2001 From: Artem Bilan Date: Fri, 19 Jun 2020 12:07:58 -0400 Subject: [PATCH] Fix deprecations from SF * Remove `whitelist` words * Resolve Sonar smells * Add `await()` for FTP file removal test: looks like this operation may fail under the stress build --- build.gradle | 1 + ...PayloadDeserializingTransformerParser.java | 6 -- .../WhiteListDeserializingConverter.java | 94 ------------------- .../support/json/JacksonJsonUtils.java | 8 +- .../PayloadDeserializingTransformer.java | 15 --- .../integration/config/spring-integration.xsd | 10 -- ...PseudoTransactionalMessageSourceTests.java | 30 +++--- .../session/FtpRemoteFileTemplateTests.java | 5 +- .../HttpRequestHandlingEndpointSupport.java | 20 ++-- .../jdbc/store/JdbcChannelMessageStore.java | 13 --- .../jdbc/store/JdbcMessageStore.java | 13 --- .../jdbc/AggregatorIntegrationTests.java | 22 ++--- ...ayerHandlerRescheduleIntegrationTests.java | 29 +++--- .../mongodb/store/MongoDbMessageStore.java | 12 --- .../support/BinaryToMessageConverter.java | 12 --- 15 files changed, 58 insertions(+), 232 deletions(-) delete mode 100644 spring-integration-core/src/main/java/org/springframework/integration/support/converter/WhiteListDeserializingConverter.java diff --git a/build.gradle b/build.gradle index b10d9ae97c..6caee4a200 100644 --- a/build.gradle +++ b/build.gradle @@ -477,6 +477,7 @@ project('spring-integration-ftp') { optionalApi "org.apache.ftpserver:ftpserver-core:$ftpServerVersion" testImplementation project(':spring-integration-file').sourceSets.test.output + testImplementation "org.hamcrest:hamcrest-core:$hamcrestVersion" } } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/config/xml/PayloadDeserializingTransformerParser.java b/spring-integration-core/src/main/java/org/springframework/integration/config/xml/PayloadDeserializingTransformerParser.java index ba4a110074..725a6a9b3a 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/config/xml/PayloadDeserializingTransformerParser.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/config/xml/PayloadDeserializingTransformerParser.java @@ -39,12 +39,6 @@ public class PayloadDeserializingTransformerParser extends AbstractTransformerPa @Override protected void parseTransformer(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) { IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, "deserializer"); - // TODO remove in 5.5 - if (element.hasAttribute("white-list")) { - parserContext.getReaderContext().error( - "the 'white-list' attribute is deprecated in favor of 'allow-list'", element); - } - IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "white-list", "allowedPatterns"); IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "allow-list", "allowedPatterns"); } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/support/converter/WhiteListDeserializingConverter.java b/spring-integration-core/src/main/java/org/springframework/integration/support/converter/WhiteListDeserializingConverter.java deleted file mode 100644 index 874049d246..0000000000 --- a/spring-integration-core/src/main/java/org/springframework/integration/support/converter/WhiteListDeserializingConverter.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright 2002-2020 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. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.integration.support.converter; - -import org.springframework.core.convert.converter.Converter; -import org.springframework.core.serializer.DefaultDeserializer; -import org.springframework.core.serializer.Deserializer; - -/** - * A {@link Converter} that delegates to a - * {@link org.springframework.core.serializer.Deserializer} to convert data in a byte - * array to an object. By default, if using a {@link DefaultDeserializer} all - * classes/packages are deserialized. If you receive data from untrusted sources, consider - * adding trusted classes/packages using {@link #setWhiteListPatterns(String...)} or - * {@link #addWhiteListPatterns(String...)}. - * - * @author Gary Russell - * @author Mark Fisher - * @author Juergen Hoeller - * - * @since 4.2.13 - * - * @deprecated since 5.4 in favor of AllowListDeserializingConverter - */ -@Deprecated -public class WhiteListDeserializingConverter extends AllowListDeserializingConverter { - - /** - * Create a {@code WhiteListDeserializingConverter} with default - * {@link java.io.ObjectInputStream} configuration, using the "latest user-defined - * ClassLoader". - */ - public WhiteListDeserializingConverter() { - super(); - } - - /** - * Create a {@code WhiteListDeserializingConverter} for using an - * {@link java.io.ObjectInputStream} with the given {@code ClassLoader}. - * @param classLoader the class loader to use for deserialization. - */ - public WhiteListDeserializingConverter(ClassLoader classLoader) { - super(classLoader); - } - - /** - * Create a {@code WhiteListDeserializingConverter} that delegates to the provided - * {@link Deserializer}. - * @param deserializer the deserializer to use. - */ - public WhiteListDeserializingConverter(Deserializer deserializer) { - super(deserializer); - } - - /** - * Set simple patterns for allowable packages/classes for deserialization. - * The patterns will be applied in order until a match is found. - * A class can be fully qualified or a wildcard '*' is allowed at the - * beginning or end of the class name. - * Examples: {@code com.foo.*}, {@code *.MyClass}. - * @param whiteListPatterns the patterns. - */ - public void setWhiteListPatterns(String... whiteListPatterns) { - setAllowedPatterns(whiteListPatterns); - } - - /** - * Add package/class patterns to the white list. - * @param patterns the patterns to add. - * @see #setWhiteListPatterns(String...) - */ - public void addWhiteListPatterns(String... patterns) { - addAllowedPatterns(patterns); - } - - protected void checkWhiteList(Class clazz) { - checkAllowList(clazz); - } - -} diff --git a/spring-integration-core/src/main/java/org/springframework/integration/support/json/JacksonJsonUtils.java b/spring-integration-core/src/main/java/org/springframework/integration/support/json/JacksonJsonUtils.java index 9b17ed4c1a..a1485507c3 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/support/json/JacksonJsonUtils.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/support/json/JacksonJsonUtils.java @@ -140,7 +140,7 @@ public final class JacksonJsonUtils { /** * A {@link TypeIdResolver} that delegates to an existing implementation - * and throws an IllegalStateException if the class being looked up is not whitelisted, + * and throws an IllegalStateException if the class being looked up is not trusted, * does not provide an explicit mixin mappings. * * @author Rob Winch @@ -167,13 +167,13 @@ public final class JacksonJsonUtils { AllowlistTypeIdResolver(TypeIdResolver delegate, String... trustedPackages) { this.delegate = delegate; if (trustedPackages != null) { - for (String whiteListPackage : trustedPackages) { - if ("*".equals(whiteListPackage)) { + for (String trustedPackage : trustedPackages) { + if ("*".equals(trustedPackage)) { this.trustedPackages.clear(); break; } else { - this.trustedPackages.add(whiteListPackage); + this.trustedPackages.add(trustedPackage); } } } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/transformer/PayloadDeserializingTransformer.java b/spring-integration-core/src/main/java/org/springframework/integration/transformer/PayloadDeserializingTransformer.java index e4d1f984fe..650fd68dfb 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/transformer/PayloadDeserializingTransformer.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/transformer/PayloadDeserializingTransformer.java @@ -49,21 +49,6 @@ public class PayloadDeserializingTransformer extends PayloadTypeConvertingTransf setConverter(new AllowListDeserializingConverter(deserializer)); } - /** - * When using a {@link AllowListDeserializingConverter} (the default) add patterns - * for packages/classes that are allowed to be deserialized. - * A class can be fully qualified or a wildcard '*' is allowed at the - * beginning or end of the class name. - * Examples: {@code com.foo.*}, {@code *.MyClass}. - * @param patterns the patterns. - * @since 4.2.13 - * @deprecated since 5.4 in favor of {@link #setAllowedPatterns(String...)} - */ - @Deprecated - public void setWhiteListPatterns(String... patterns) { - setAllowedPatterns(patterns); - } - /** * When using a {@link AllowListDeserializingConverter} (the default) add patterns * for packages/classes that are allowed to be deserialized. diff --git a/spring-integration-core/src/main/resources/org/springframework/integration/config/spring-integration.xsd b/spring-integration-core/src/main/resources/org/springframework/integration/config/spring-integration.xsd index 3fe0215216..e2bc87e324 100644 --- a/spring-integration-core/src/main/resources/org/springframework/integration/config/spring-integration.xsd +++ b/spring-integration-core/src/main/resources/org/springframework/integration/config/spring-integration.xsd @@ -2787,16 +2787,6 @@ - - - - [DEPRECATED] - When using the default Deserializer, a list of package/class patterns indicating - classes that are allowed to be deserialized. Consider providing this if you receive - data from untrusted sources. Example: "com.mycom.*, com.yourcom.*". - - - diff --git a/spring-integration-core/src/test/java/org/springframework/integration/endpoint/PseudoTransactionalMessageSourceTests.java b/spring-integration-core/src/test/java/org/springframework/integration/endpoint/PseudoTransactionalMessageSourceTests.java index 5c15c3c313..3d9e0e0636 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/endpoint/PseudoTransactionalMessageSourceTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/endpoint/PseudoTransactionalMessageSourceTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -24,7 +24,7 @@ import java.lang.reflect.Method; import java.util.concurrent.atomic.AtomicInteger; import org.apache.commons.logging.Log; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.mockito.Mockito; import org.springframework.beans.DirectFieldAccessor; @@ -50,7 +50,6 @@ import org.springframework.messaging.MessageChannel; import org.springframework.messaging.PollableChannel; import org.springframework.messaging.support.GenericMessage; import org.springframework.transaction.support.TransactionSynchronization; -import org.springframework.transaction.support.TransactionSynchronizationAdapter; import org.springframework.transaction.support.TransactionSynchronizationManager; import org.springframework.transaction.support.TransactionSynchronizationUtils; import org.springframework.transaction.support.TransactionTemplate; @@ -87,7 +86,7 @@ public class PseudoTransactionalMessageSourceTests { @Override public Message receive() { - GenericMessage message = new GenericMessage("foo"); + GenericMessage message = new GenericMessage<>("foo"); IntegrationResourceHolder holder = (IntegrationResourceHolder) TransactionSynchronizationManager.getResource(this); holder.addAttribute("baz", "qux"); @@ -141,7 +140,7 @@ public class PseudoTransactionalMessageSourceTests { @Override public Message receive() { - GenericMessage message = new GenericMessage("foo"); + GenericMessage message = new GenericMessage<>("foo"); IntegrationResourceHolder holder = (IntegrationResourceHolder) TransactionSynchronizationManager.getResource(this); holder.addAttribute("baz", "qux"); @@ -192,7 +191,7 @@ public class PseudoTransactionalMessageSourceTests { @Override public Message receive() { - GenericMessage message = new GenericMessage("foo"); + GenericMessage message = new GenericMessage<>("foo"); ((IntegrationResourceHolder) TransactionSynchronizationManager.getResource(this)) .addAttribute("baz", testMessage); return message; @@ -235,7 +234,7 @@ public class PseudoTransactionalMessageSourceTests { @Override public Message receive() { - GenericMessage message = new GenericMessage("foo"); + GenericMessage message = new GenericMessage<>("foo"); IntegrationResourceHolder holder = (IntegrationResourceHolder) TransactionSynchronizationManager.getResource(this); holder.addAttribute("baz", "qux"); @@ -280,7 +279,7 @@ public class PseudoTransactionalMessageSourceTests { @Override public Message receive() { - GenericMessage message = new GenericMessage("foo"); + GenericMessage message = new GenericMessage<>("foo"); ((IntegrationResourceHolder) TransactionSynchronizationManager.getResource(this)) .addAttribute("baz", "qux"); return message; @@ -323,7 +322,7 @@ public class PseudoTransactionalMessageSourceTests { @Override public Message receive() { - GenericMessage message = new GenericMessage("foo"); + GenericMessage message = new GenericMessage<>("foo"); ((IntegrationResourceHolder) TransactionSynchronizationManager.getResource(this)) .addAttribute("baz", "qux"); return message; @@ -361,17 +360,13 @@ public class PseudoTransactionalMessageSourceTests { final AtomicInteger txSyncCounter = new AtomicInteger(); - TransactionSynchronizationFactory syncFactory = new TransactionSynchronizationFactory() { + TransactionSynchronizationFactory syncFactory = key -> new TransactionSynchronization() { @Override - public TransactionSynchronization create(Object key) { - return new TransactionSynchronizationAdapter() { - @Override - public void afterCompletion(int status) { - txSyncCounter.incrementAndGet(); - } - }; + public void afterCompletion(int status) { + txSyncCounter.incrementAndGet(); } + }; adapter.setTransactionSynchronizationFactory(syncFactory); @@ -412,6 +407,7 @@ public class PseudoTransactionalMessageSourceTests { } } + @Configuration @EnableIntegration public static class TestTxSyncConfiguration { diff --git a/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/session/FtpRemoteFileTemplateTests.java b/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/session/FtpRemoteFileTemplateTests.java index d30649a718..0a76b115a0 100644 --- a/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/session/FtpRemoteFileTemplateTests.java +++ b/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/session/FtpRemoteFileTemplateTests.java @@ -18,12 +18,14 @@ package org.springframework.integration.ftp.session; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; +import static org.awaitility.Awaitility.await; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; +import java.time.Duration; import java.util.UUID; import org.apache.commons.net.ftp.FTPClient; @@ -92,8 +94,7 @@ public class FtpRemoteFileTemplateTests extends FtpTestSupport { template.execute((SessionCallbackWithoutResult) session -> { assertThat(session.remove("foo/foobar.txt")).isTrue(); assertThat(session.rmdir("foo/bar/")).isTrue(); - FTPFile[] files = session.list("foo/"); - assertThat(files.length).isEqualTo(0); + await().atMost(Duration.ofSeconds(10)).until(() -> session.list("foo/"), files -> files.length == 0); assertThat(session.rmdir("foo/")).isTrue(); }); assertThat(template.exists("foo")).isFalse(); 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 f804d02c50..07e40a0388 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-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -63,6 +63,7 @@ import org.springframework.messaging.MessageChannel; import org.springframework.messaging.MessageHeaders; import org.springframework.messaging.MessagingException; import org.springframework.messaging.converter.MessageConversionException; +import org.springframework.messaging.support.ErrorMessage; import org.springframework.util.Assert; import org.springframework.util.CollectionUtils; import org.springframework.util.LinkedMultiValueMap; @@ -270,6 +271,7 @@ public abstract class HttpRequestHandlingEndpointSupport extends BaseHttpInbound Map headers = getHeaderMapper().toHeaders(httpEntity.getHeaders()); Object payload = null; Message message = null; + boolean expectReply = isExpectReply(); try { if (getPayloadExpression() != null) { // create payload based on SpEL @@ -300,9 +302,14 @@ public abstract class HttpRequestHandlingEndpointSupport extends BaseHttpInbound new MessageConversionException("Cannot create request message", ex); MessageChannel errorChannel = getErrorChannel(); if (errorChannel != null) { - this.messagingTemplate.send(errorChannel, - buildErrorMessage(null, - conversionException)); + ErrorMessage errorMessage = buildErrorMessage(null, conversionException); + if (expectReply) { + return this.messagingTemplate.sendAndReceive(errorChannel, errorMessage); + } + else { + this.messagingTemplate.send(errorChannel, errorMessage); + return null; + } } else { throw conversionException; @@ -310,7 +317,8 @@ public abstract class HttpRequestHandlingEndpointSupport extends BaseHttpInbound } Message reply = null; - if (isExpectReply()) { + + if (expectReply) { try { reply = sendAndReceiveMessage(message); } @@ -501,7 +509,7 @@ public abstract class HttpRequestHandlingEndpointSupport extends BaseHttpInbound return new RequestEntity<>(requestBody, request.getHeaders(), request.getMethod(), request.getURI()); } - @SuppressWarnings({ "unchecked", "rawtypes" }) + @SuppressWarnings({"unchecked", "rawtypes"}) protected Object extractRequestBody(ServletServerHttpRequest request) throws IOException { MediaType contentType = request.getHeaders().getContentType(); if (contentType == null) { 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 184019f7d4..3f76bb3754 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 @@ -193,19 +193,6 @@ public class JdbcChannelMessageStore implements PriorityCapableChannelMessageSto this.deserializer = new AllowListDeserializingConverter((Deserializer) deserializer); } - /** - * Add patterns for packages/classes that are allowed to be deserialized. A class can - * be fully qualified or a wildcard '*' is allowed at the beginning or end of the - * class name. Examples: {@code com.foo.*}, {@code *.MyClass}. - * @param patterns the patterns. - * @since 4.2.13 - * @deprecated since 5.4 in favor of {@link #addAllowedPatterns(String...)} - */ - @Deprecated - public void addWhiteListPatterns(String... patterns) { - addAllowedPatterns(patterns); - } - /** * Add patterns for packages/classes that are allowed to be deserialized. A class can * be fully qualified or a wildcard '*' is allowed at the beginning or end of the 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 e77390764e..bf63c2b060 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 @@ -250,19 +250,6 @@ public class JdbcMessageStore extends AbstractMessageGroupStore implements Messa this.deserializer = new AllowListDeserializingConverter((Deserializer) deserializer); } - /** - * Add patterns for packages/classes that are allowed to be deserialized. A class can - * be fully qualified or a wildcard '*' is allowed at the beginning or end of the - * class name. Examples: {@code com.foo.*}, {@code *.MyClass}. - * @param patterns the patterns. - * @since 4.2.13 - * @deprecated since 5.4 in favor of {@link #addAllowedPatterns(String...)} - */ - @Deprecated - public void addWhiteListPatterns(String... patterns) { - addAllowedPatterns(patterns); - } - /** * Add patterns for packages/classes that are allowed to be deserialized. A class can * be fully qualified or a wildcard '*' is allowed at the beginning or end of the diff --git a/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/AggregatorIntegrationTests.java b/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/AggregatorIntegrationTests.java index 93f954f690..4542212b0b 100644 --- a/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/AggregatorIntegrationTests.java +++ b/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/AggregatorIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2019 the original author or authors. + * Copyright 2014-2020 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,9 +23,8 @@ import java.util.Map; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; -import org.junit.After; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.integration.IntegrationMessageHeaderAccessor; @@ -37,10 +36,8 @@ import org.springframework.messaging.MessageHandler; import org.springframework.messaging.MessagingException; import org.springframework.messaging.support.GenericMessage; import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; import org.springframework.transaction.support.TransactionSynchronization; -import org.springframework.transaction.support.TransactionSynchronizationAdapter; import org.springframework.transaction.support.TransactionSynchronizationManager; /** @@ -48,8 +45,7 @@ import org.springframework.transaction.support.TransactionSynchronizationManager * * @since 4.1 */ -@ContextConfiguration -@RunWith(SpringJUnit4ClassRunner.class) +@SpringJUnitConfig @DirtiesContext public class AggregatorIntegrationTests { @@ -62,14 +58,14 @@ public class AggregatorIntegrationTests { @Autowired private AggregatingMessageHandler aggregatingMessageHandler; - @After + @AfterEach public void tearDown() { this.aggregatingMessageHandler.stop(); } @Test public void testTransactionalAggregatorGroupTimeout() throws InterruptedException { - this.transactionalAggregatorInput.send(new GenericMessage(1, stubHeaders(1, 2, 1))); + this.transactionalAggregatorInput.send(new GenericMessage<>(1, stubHeaders(1, 2, 1))); assertThat(RollbackTxSync.latch.await(20, TimeUnit.SECONDS)).isTrue(); @@ -78,7 +74,7 @@ public class AggregatorIntegrationTests { } private Map stubHeaders(int sequenceNumber, int sequenceSize, int correlationId) { - Map headers = new HashMap(); + Map headers = new HashMap<>(); headers.put(IntegrationMessageHeaderAccessor.SEQUENCE_NUMBER, sequenceNumber); headers.put(IntegrationMessageHeaderAccessor.SEQUENCE_SIZE, sequenceSize); headers.put(IntegrationMessageHeaderAccessor.CORRELATION_ID, correlationId); @@ -96,7 +92,7 @@ public class AggregatorIntegrationTests { } - private static class RollbackTxSync extends TransactionSynchronizationAdapter { + private static class RollbackTxSync implements TransactionSynchronization { public static CountDownLatch latch = new CountDownLatch(1); diff --git a/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/DelayerHandlerRescheduleIntegrationTests.java b/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/DelayerHandlerRescheduleIntegrationTests.java index 8807b70533..71472530d2 100644 --- a/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/DelayerHandlerRescheduleIntegrationTests.java +++ b/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/DelayerHandlerRescheduleIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -22,10 +22,9 @@ import static org.assertj.core.api.Assertions.fail; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; import org.springframework.context.support.AbstractApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; @@ -35,7 +34,7 @@ import org.springframework.integration.store.MessageGroup; import org.springframework.integration.store.MessageGroupStore; import org.springframework.integration.store.SimpleMessageGroup; import org.springframework.integration.support.MessageBuilder; -import org.springframework.integration.test.support.LongRunningIntegrationTest; +import org.springframework.integration.test.condition.LongRunningTest; import org.springframework.integration.util.UUIDConverter; import org.springframework.jdbc.datasource.embedded.EmbeddedDatabase; import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder; @@ -47,23 +46,20 @@ import org.springframework.messaging.MessagingException; import org.springframework.messaging.PollableChannel; import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; import org.springframework.transaction.support.TransactionSynchronization; -import org.springframework.transaction.support.TransactionSynchronizationAdapter; import org.springframework.transaction.support.TransactionSynchronizationManager; /** * @author Artem Bilan * @author Gary Russell */ +@LongRunningTest public class DelayerHandlerRescheduleIntegrationTests { public static final String DELAYER_ID = "delayerWithJdbcMS"; public static EmbeddedDatabase dataSource; - @Rule - public LongRunningIntegrationTest longTests = new LongRunningIntegrationTest(); - - @BeforeClass + @BeforeAll public static void init() { dataSource = new EmbeddedDatabaseBuilder() .setType(EmbeddedDatabaseType.H2) @@ -72,12 +68,12 @@ public class DelayerHandlerRescheduleIntegrationTests { .build(); } - @AfterClass + @AfterAll public static void destroy() { dataSource.shutdown(); } - @Test //INT-1132 + @Test public void testDelayerHandlerRescheduleWithJdbcMessageStore() throws Exception { AbstractApplicationContext context = new ClassPathXmlApplicationContext("DelayerHandlerRescheduleIntegrationTests-context.xml", getClass()); @@ -142,7 +138,7 @@ public class DelayerHandlerRescheduleIntegrationTests { context.close(); } - @Test //INT-2649 + @Test public void testRollbackOnDelayerHandlerReleaseTask() throws Exception { AbstractApplicationContext context = new ClassPathXmlApplicationContext("DelayerHandlerRescheduleIntegrationTests-context.xml", getClass()); @@ -172,6 +168,9 @@ public class DelayerHandlerRescheduleIntegrationTests { @SuppressWarnings("unused") private static class ExceptionMessageHandler implements MessageHandler { + ExceptionMessageHandler() { + } + @Override public void handleMessage(Message message) throws MessagingException { TransactionSynchronizationManager.registerSynchronization(new RollbackTxSync()); @@ -180,7 +179,7 @@ public class DelayerHandlerRescheduleIntegrationTests { } - private static class RollbackTxSync extends TransactionSynchronizationAdapter { + private static class RollbackTxSync implements TransactionSynchronization { public static CountDownLatch latch = new CountDownLatch(2); diff --git a/spring-integration-mongodb/src/main/java/org/springframework/integration/mongodb/store/MongoDbMessageStore.java b/spring-integration-mongodb/src/main/java/org/springframework/integration/mongodb/store/MongoDbMessageStore.java index 9fc2b751b8..434d107d95 100644 --- a/spring-integration-mongodb/src/main/java/org/springframework/integration/mongodb/store/MongoDbMessageStore.java +++ b/spring-integration-mongodb/src/main/java/org/springframework/integration/mongodb/store/MongoDbMessageStore.java @@ -172,18 +172,6 @@ public class MongoDbMessageStore extends AbstractMessageGroupStore this.applicationContext = applicationContext; } - /** - * Add patterns for packages/classes that are allowed to be deserialized. A class can - * be fully qualified or a wildcard '*' is allowed at the beginning or end of the - * class name. Examples: {@code com.foo.*}, {@code *.MyClass}. - * @param patterns the patterns. - * @deprecated since 5.4 in favor of {@link #addAllowedPatterns(String...)} - */ - @Deprecated - public void addWhiteListPatterns(String... patterns) { - addAllowedPatterns(patterns); - } - /** * Add patterns for packages/classes that are allowed to be deserialized. A class can * be fully qualified or a wildcard '*' is allowed at the beginning or end of the diff --git a/spring-integration-mongodb/src/main/java/org/springframework/integration/mongodb/support/BinaryToMessageConverter.java b/spring-integration-mongodb/src/main/java/org/springframework/integration/mongodb/support/BinaryToMessageConverter.java index 2154cb1dd5..eb060f73ee 100644 --- a/spring-integration-mongodb/src/main/java/org/springframework/integration/mongodb/support/BinaryToMessageConverter.java +++ b/spring-integration-mongodb/src/main/java/org/springframework/integration/mongodb/support/BinaryToMessageConverter.java @@ -38,18 +38,6 @@ public class BinaryToMessageConverter implements Converter> { return (Message) this.deserializingConverter.convert(source.getData()); } - /** - * Add patterns for packages/classes that are allowed to be deserialized. A class can - * be fully qualified or a wildcard '*' is allowed at the beginning or end of the - * class name. Examples: {@code com.foo.*}, {@code *.MyClass}. - * @param patterns the patterns. - * @deprecated since 5.4 in favor of {@link #addAllowedPatterns(String...)} - */ - @Deprecated - public void addWhiteListPatterns(String... patterns) { - this.deserializingConverter.addAllowedPatterns(patterns); - } - /** * Add patterns for packages/classes that are allowed to be deserialized. A class can * be fully qualified or a wildcard '*' is allowed at the beginning or end of the