Commit Graph

11032 Commits

Author SHA1 Message Date
freyan929
2e9beada0b GH-3858: Add ImapIdleChASpec.reconnectDelay()
Fixes https://github.com/spring-projects/spring-integration/issues/3858
2022-07-25 21:46:14 -04:00
Artem Bilan
573c29793a Fix SIK module for latest SK compatibility
Spring for Apache Kafka does not produce `ListenableFuture` anymore.

* Rework `KafkaProducerMessageHandler` to deal with the `CompletableFuture` from now on
* Add support for `CompletableFuture` replies handling into `AbstractMessageProducingHandler`
* Remove redundant cast in the `DispatcherHasNoSubscribersTests`
2022-07-25 17:19:19 -04:00
Artem Bilan
0422486409 Fix for latest compatibility 2022-07-25 12:27:17 -04:00
Spring Builds
31907ec1d9 [artifactory-release] Next development version 2022-07-20 18:20:22 +00:00
Spring Builds
31cd7a16a8 [artifactory-release] Release version 6.0.0-M4 2022-07-20 18:20:18 +00:00
Artem Bilan
821f09995d Upgrade dependencies; prepare for release 2022-07-20 13:38:43 -04:00
Artem Vozhdayenko
50769d0350 GH-3839: Migrate MongoDB tests to Testcontainers
Fixes https://github.com/spring-projects/spring-integration/issues/3839

* Create a new base interface for Mongo container-based tests
* Migrate all tests to JUnit5
* Remove obsolete classes related to JUnit4 Mongo rule
* Fix code style & readability here and there, a few Sonar issues
* Fix failing test `validateWithConfiguredPollerFlow`
* * This test was failing with Mongo error
`$and/$or/$nor must be a nonempty array`. The cause was too small
polling ratio of the update query, the consecutive read queries
failed as no 'Oleg' document was in collection after ~100 ms.

Couple of changes after the pull request review:
* Get back the blank lines in test classes
* Get back the blank lines for some inner classes
* Eliminate bad renaming consequences
* Remove a couple of garbage todos
* Couple of places with code cleanup
2022-07-19 16:56:18 -04:00
Artem Bilan
850671698b Disable some time-sensitive tests on CI
**Cherry-pick to `5.5.x`**
2022-07-19 12:32:08 -04:00
Artem Bilan
92630dda70 GH-3843: propagate ErrorMessage.originalMes in MH
Fixes https://github.com/spring-projects/spring-integration/issues/3843

The `MessageHistory.write()` is missing the `ErrorMessage.originalMessage`
on creating a new `ErrorMessage` with message history header

* Reuse an `ErrorMessage.originalMessage` for newly created `ErrorMessage`
after populating the message history header

**Cherry-pick to `5.5.x`**
2022-07-18 15:48:39 -04:00
Artem Bilan
8f44870837 GH-3827: Fix RemoteFile GET STREAM session leak
Fixes https://github.com/spring-projects/spring-integration/issues/3827

The `AbstractRemoteFileOutboundGateway.doGet()` for a `STREAM` option
does not close the `session` in case of error.
This may lead to some leaks or exhausted caches

* Close `session` in the `catch()` of the `AbstractRemoteFileOutboundGateway.doGet()`
* Adjust the `SftpServerOutboundTests` to configure a `CachingSessionFactory`
for the `testStream()` to verify there is no leaks attempting to
`GET STREAM` non-existing remote file twice

**Cherry-pick to `5.5.x`**
2022-07-18 14:07:34 -04:00
Artem Bilan
d9a42c9e14 Fix KafkaOutAdapterParserTests race condition
The `Future` for `Producer.send()` can be fulfilled before
we return it (`isDone()`), so `KafkaTemplate` short-circuits
with a `KafkaException`.

* Modify `KafkaOutboundAdapterParserTests.testSyncMode()`
to assert against `KafkaException` which may be thrown earlier
then previously expected `KafkaProducerException`

**Cherry-pick to `5.5.x`**
2022-07-18 13:05:42 -04:00
Artem Vozhdayenko
1c461a3e2c GH-3840: Migrate Redis tests to Testcontainers
Fixes https://github.com/spring-projects/spring-integration/issues/3840

* Create a new abstraction `RedisTest` for Testcontainers-based tests
* Move existing common utility methods to the new interface
* Migrate all existing Redis tests to use this new `RedisTest` interface
* Migrate all existing Redis tests to JUnit5
* Make all existing Redis tests confirming to JUnit5 standards, such as
default methods and classes visibility instead of public
* Add a dependency for parametrized tests in JUnit5
* Improve assertions readability across tests, for instance:
assertThat(thing.size()).isEqualTo(2) -> assertThat(thing).hasSize(2)
* Add real assertions to
`RedisLockRegistryTests.twoRedisLockRegistryTest` (earlier it did not
have assertions at all)
* Reformat, rearrange and cleanup the code
* Fix a couple of small changes after the code review:
* Change base interface name to be consistent with other similar places
* Typo in javadocs
* Small tests readability improvement regarding assertions
* Add `opens java.util` to `spring-integration-redis`
 to satisfy a `ReactiveRedisStreamMessageHandlerTests.testMessageWithListPayload()`
 requirements
2022-07-15 14:47:49 -04:00
Artem Bilan
79d31b2329 Remove ulinkAvailable test for RedisLockRegistry
The logic of the test does not reflect the state of the
`RedisLockRegistry` around `ulinkAvailable` property:
we don't check the Redis version anymore, but try to call
`UNLINK` command.
Then we reset `ulinkAvailable` to `false` to call regular `DEL`
for the rest of `RedisLockRegistry` life

The `RedisAvailableRule` marks `testUlink()` as passed even without
calling it.
We are not going to look into fixing the rule since we are migrating
to Testcontainers: https://github.com/spring-projects/spring-integration/issues/3840
2022-07-13 10:52:37 -04:00
Artem Bilan
7f631fc947 Upgrade to MongoDB Driver 4.7.0-beta0 2022-07-12 16:36:09 -04:00
Artem Bilan
a67c4d9ff9 Fix DelayerUsageTests with a isCloseTo() 2022-07-12 15:29:32 -04:00
Artem Bilan
cd6b0c5bbf DelayHandler: Improve Instant handling 2022-07-12 15:10:04 -04:00
Artem Vozhdayenko
f349e1a114 GH-3804: Migrate SMB unit tests to Testcontainers
Fixes https://github.com/spring-projects/spring-integration/issues/3804

Instead of manual SMB server setup and preparation, make it all
automated using convenient Testcontainers library and a bit of extra
code executed before tests.

* Change `localhost` to `127.0.0.1` for a proper integration with docker container
* A few new config values to support container environment, like tmpFs,
share permissions and a dynamic port value
* Introduce Testcontainers API for container management
* Few configuration changes to support docker container usage
* Automatic dirs and files layout creation in `@BeforeAll`
* A few bugfixes where the assertion has not been done actually
* Couple of small changes related to assertions readability as well
* Use `warn` as default logging level for the SMB tests
* Refactor an `SmbTests` a bit: moving its `createFilesInSmbShare()` to
the `SmbTestSupport` since that files tree can be useful for any other
similar integration tests in the future
* Use `TestUtils.applySystemFileSeparator()` for cross-platform file paths
2022-07-12 14:27:49 -04:00
Artem Bilan
b074f1961f Upgrade to Hibernate 6.1.x; fix JPA tests 2022-07-12 12:18:19 -04:00
Artem Bilan
5ded860e78 Remove unused import in OSDelegatingFileTailingMP 2022-07-11 11:53:18 -04:00
Artem Bilan
f85423a436 Fix more deprecations around TaskScheduler 2022-07-11 11:41:38 -04:00
Artem Bilan
4a55fa3188 Fix IntegrationMBeanExporter logic for endpoints
Related to https://stackoverflow.com/questions/72851234/error-in-startup-application-when-using-serviceactivator-in-spring-cloud-stream

The `MessagingAnnotationPostProcessor` register an `endpoint` bean for Messaging Annotation on POJO methods.
The `IntegrationMBeanExporter` post-process such a bean and registers respective MBean.
It does this not in optimal way scanning all the `IntegrationConsumer` beans for requested `MessageHandler`
which may cause a `BeanCurrentlyInCreationException`.

* Rework the logic of the `IntegrationMBeanExporter.postProcessAbstractEndpoint()` to propagate provided endpoint
for the monitor registration to bypass application context scanning for matched name.
* Swap `equals()` for `monitor` since an `extractTarget()` may return `null`
* Some other code clean in the `IntegrationMBeanExporter`
* Change one of the `@ServiceActivator` in the configuration for the `ScatterGatherHandlerIntegrationTests`
to POJO method.
However, this didn't fail for me with original code unlike in the sample application provided in the mentioned SO thread.

**Cherry-pick to `main`**
2022-07-11 10:31:19 -04:00
Artem Bilan
733eb40e7b ClassUtils clean & deprecation in JmsOutGateway
* Remove previously deprecated methods with typos from the `ClassUtils`
* Optimize `ClassUtils` logic via `KotlinDetector.isKotlinPresent()` condition
* Resolve deprecation warnings in the `JmsOutboundGateway` around `TaskScheduler`
2022-07-09 16:11:09 -04:00
Artem Bilan
f12248f1ec ClassUtils: deprecate methods with typos
The `ClassUtils.isKotlinFaction0()` and `ClassUtils.isKotlinFaction1()`
are wrong names.

* Deprecate `ClassUtils.isKotlinFaction0()` and `ClassUtils.isKotlinFaction1()`
in favor of newly introduced `isKotlinFunction0()` and `isKotlinFunction1()`

**Cherry-pick to `main`**
2022-07-09 15:37:40 -04:00
Artem Bilan
e0f137905a Fix compatibility with the latest SF
* Mostly changes are related to the `TaskScheduler` and `Trigger` APIs
* Migrate to `micrometer-tracing` dependency
* Rework `SocketTestUtils` to use a `InetAddress.getLocalHost()`
for more stability and performance on Windows
* Fix docs for new `PeriodicTrigger` API
2022-07-08 17:36:15 -04:00
Artem Vozhdayenko
64aa4d5348 GH-3666: Revise TcpNioConnectionTests
Fixes: https://github.com/spring-projects/spring-integration/issues/3666

Seems like Windows socket connect to the loopback address fails sometimes because of a bug in the implementation of OpenJDK. 

* Changing loopback addr with the actual IP addr seems to help.
* Fix `TcpNioConnectionTests.testMultiAccept()` and `testNoMultiAccept()` to rely on the ` InetAddress.getLocalHost()` 
instead of `localhost` string which has to be resolved to the address yet in the testing loop
2022-07-08 11:26:50 -04:00
Artem Bilan
2e219ffbd8 Exclude aopalliance dep from micrometer-tracing 2022-07-06 15:10:36 -04:00
Artem Bilan
72c448b897 Upgrade to Kotlin 1.7; add Micrometer tracing dep 2022-07-06 15:05:31 -04:00
Zahid Khan
ae1aaad67a Check for null before setting maxSubscribers
The `DirectChannel` doesn't check a result of the `getIntegrationProperty()`.
This may cause NPE problem with unconditional `setMaxSubscribers(int)` call.

* Check `Integer max` for `null` before propagating to the `setMaxSubscribers()`
2022-07-06 14:18:34 -04:00
Artem Bilan
bb91fd3cb3 Some documentations clean up 2022-07-05 16:12:16 -04:00
Artem Vozhdayenko
53dd050c5b GH-3623: Deprecarte an IntegrationFlows
Fixes https://github.com/spring-projects/spring-integration/issues/3623

* `IntegrationFlow` refactoring
* Apply several code style improvements and good practices
* Code style: no empty lines for methods javadocs
* make deprecated implementation reuse actual one instead of the copy-paste approach
* add whats-new comments
* Fix whats-new page according to standards
2022-07-05 15:47:30 -04:00
Zahid Khan
63759d76b9 Add assertions on utility classes in IP module
* Add assertions and comment on the utility class.
Added assertion on the utility class, so that it can't be mistakenly ever initialized in the class.
* Add exception message for RegexUtils
* Add exception message "Class Instantiation not allowed." for the TestingUtilities
2022-06-30 15:54:22 -04:00
Artem Bilan
2a5ddabd26 More test fixes for latest SF compatibility 2022-06-28 12:44:40 -04:00
Artem Bilan
2022c40d55 Fix compatibility with the latest SF
* Upgrade Spring dependencies to the latest SNAPSHOTs
* Fix tests to verify against stack traces: the message
of the `NestedRuntimeException`  does not include the nested exception information.
Related to https://github.com/spring-projects/spring-framework/issues/25162
* Fix `JdbcMessageStore` and `DefaultLockRepository` to rely on the `DataIntegrityViolationException`
instead of only its `DuplicateKeyException` extension.
This is the current behavior of the SQL errors translation
* Disable `WebFluxDslTests.testValidation()` - doesn't subscribe to the reply somehow...
* Refine `SimplePool.PoolSemaphore.reducePermits()`
2022-06-27 20:30:14 -04:00
Gary Russell
979b8417ef GH-3826: Fix reducePermits
Must not go negative.
2022-06-27 14:37:17 -04:00
Artem Bilan
6fe59a76aa GH-3826: Fix SimplePool for resizing from MAX
Fixes https://github.com/spring-projects/spring-integration/issues/3826

By default, the `SimplePool` is used with an `Integer.MAX_VALUE` pool size.
There is a performance degradation in the `setPoolSize()` when we try to
decrease the pool size: the `while` for `permits.tryAcquire()` is too long
close to the current `Integer.MAX_VALUE` pool size

* Revise the logic in the `setPoolSize()` to use `Semaphore.reducePermits()`
instead of the loop.
* Change the calculation for a new pool size for the current pool state:
or it is a size of a new request, or iti s equal to the `inUse.size()`.
It will be reduced on subsequent `releaseItem()` calls
* Reduce the number of `available` according a new pool size based on the `inUse`.
So, if `inUse > newPoolSize`, the `available` is cleared.
Otherewise, it is reduced to the number which would give `newPoolSize` together
with the `inUse` size

**Cherry-pick to `5.5.x`**
2022-06-27 13:47:55 -04:00
Artem Bilan
b14e0014da Fix MongoDbAvailableRule for assumeTrue()
Currently, the `MongoDbAvailableRule` logs a warning about missed availability
of the MongoDb server and returns from the `Statement.evaluate()` making the
test not ignored but as passed

* Fix the exception handling in the `MongoDbAvailableRule` for the `Statement`
to call `Assume.assumeTrue()` instead of the plain logging to mark the test as
ignored.
This will make a JUnit test report looking correctly and also will let Sonar Cube
to report test coverage as adequate

**Cherry-pick to `5.5.x`**
2022-06-23 16:33:58 -04:00
Artem Bilan
04c7a87bd9 Use lookupHost = false by default for TCP & UDP (#3825)
* Use `lookupHost = false` by default for TCP & UDP

The applications these days more and more are deployed and managed in the containers
where DNS is not configured by default.
Having `lookupHost = true` by default leads to a bad experience when some delays happen
for reverse host lookups.

* Use `lookupHost = false` by default for both TCP & UDP to have a reliable behavior
independently of the environment.
The `hostName` is used for `connectionId` and as a header in the message -
semantically it doesn't matter for the application logic what value is present over there.

* * Fix language in docs

Co-authored-by: Gary Russell <grussell@vmware.com>

Co-authored-by: Gary Russell <grussell@vmware.com>
2022-06-22 13:23:03 -04:00
Lucas Bowler
8cf5f9083b GH-3822: Reconnection for MQTTv5 channel adapters
Fixes: https://github.com/spring-projects/spring-integration/issues/3822

* Apply spring-framework code style on modified class
* Remove unwanted formatting
* Take pull request comments into account
* Code and JavaDocs clean up
* Improve `Mqttv5BackToBackAutomaticReconnectTests` removing non-related code
* Improve `mqtt.adoc` for this new manual reconnection feature

**Cherry-pick to `5.5.x`**
2022-06-17 14:06:04 -04:00
unseok kim
cf6ce961a2 GH-3805: Introduce RedisLockRegistry.RedisLockType mode
Fixes https://github.com/spring-projects/spring-integration/issues/3805

The Redis Pub-Sub doesn't work in all the environment, therefore there has to
be a choice to use old busy-spin algorithm

* Change to select between spinLock method and pub-sub method
* Make spinLock as a default one to let the `RedisLockRegistry` work everywhere
* Fix javadoc, convention, lazy init
* Fix javadoc, convention
* Code clean up and docs for `RedisLockType` feature

**Cherry-pick to 5.5.x**
2022-06-08 13:15:30 -04:00
Artem Bilan
e855f13d8e GH-3797: Improve batch processing in the framework (#3820)
* GH-3797: Improve batch processing in the framework

Fixes https://github.com/spring-projects/spring-integration/issues/3797

* Handle `Message` items of the `Iterable` payload properly in the `JdbcMessageHandler`.
Otherwise, they've been wrapped into an extra `Message`
* Produce a single message with a `Collection<Message<?>>` payload in the `AggregatingMessageHandler`
when the `getOutputProcessor()` is not an instance of `SimpleMessageGroupProcessor`
* Mention these changes in docs
* Point to the error handling sample from docs

* * Fix language in docs

Co-authored-by: Gary Russell <grussell@vmware.com>

Co-authored-by: Gary Russell <grussell@vmware.com>
2022-06-07 10:14:53 -04:00
Artem Bilan
4f49038e17 Use bean CL for JdbcMessageStore.deserializer
Related to https://stackoverflow.com/questions/72305387/spring-integration-delayer-starts-sending-null-message-payloads-when-switched

In some async use-cases (e.g. `DelayHandler`), the context classloader
might be different for the data to be deserialized from message store.

* Fix `JdbcMessageStore` to populate a bean `ClassLoader` into default
`AllowListDeserializingConverter` from the application context.
The provided `Deserializer` must ensure such a `ClassLoader` itself
* Add warning message to the `LambdaMessageProcessor` when converter
returns `null` for the payload it cannot convert to expected type.
Cannot be raised as error since some applications may already rely
on the `null` conversion result in their method arguments

**Cherry-pick to `5.5.x`**
2022-06-01 12:46:17 -04:00
Artem Bilan
cdcc986d11 Fix KafkaMDChannelAdapter error handling
Current `IntegrationRecordMessageListener.onMessage()`
send a conversion error to the `errorChannel`, but
it does not return if it was successful leading to
the NPE `enhanceHeadersAndSaveAttributes()` because the `message`
is null

* Change the `IntegrationRecordMessageListener.onMessage()` logic to check
the result of the `sendErrorMessageIfNecessary()` and return immediately
if success.
Rethrow an exception otherwise.
2022-05-31 14:08:07 -04:00
Gregory Bragg
7174e8840b Add XSD for new SMB components
* Add namespace handler support for new XSD configs
* Add JUnit tests for outbound gateway XML config
* Add JUnit tests for streaming inbound adapter XML config
* Add Javadoc to new parser classes as per PR feedback
* Some code clean up
2022-05-31 13:32:44 -04:00
Gregory Bragg
0cf1dfee7e Some improvements for SMB module
* Improve permission information returned in `SmbFileInfo`
* Improve documentation for `SmbFileInfo.getPermissions()`
* Add Junit tests to verify all outbound gateway functionality
* Clean test directory of mistakenly migrated SMB extension code
2022-05-26 12:55:37 -04:00
Artem Bilan
751d8084b4 Improve Hazelcast test suite performance
* Add recommended JVM args to the Gradle module for HZ performance
* Move `IdempotentReceiverIntegrationTests` from JMX module to HZ for consistency
* Remove component scan from the `HazelcastIntegrationOutboundTestConfiguration` - redundant
* Use `HazelcastInstance.shutdown()` during normal context lifecycle.
The `@AfterClass` may happen early, so the `stop()` of the channel adapters may fail with
an exception that HZ is not available causing the `LifecycleProcessor` to wait for 30 seconds
on the lifecycle barrier
* Wrap `AbstractEndpoint.doStop()` call into `try..catch` to log error instead of re-throwing
to avoid the mentioned above 30 secs delay of the application context stop
2022-05-25 16:45:00 -04:00
Robert Höglund
a322f5c35d Move spring-integration-hazelcast from extensions
* Update javadocs
* Upgrade from log4j to log4j2
* Remove unnecessary test deps.
* Change from implmementation to api
* Remove unneeded test deps.
* Fix HZ XSD to be "versionless"
* Use `com.google.code.findbugs:annotations` dep to avoid warning from HZ code base
2022-05-25 12:26:28 -04:00
Dominic Stew
040438f5e9 Refresh README
* Modernize the homepage of Spring Integration
* Improve README.md file, so it has examples, explanations, and logo
2022-05-24 12:31:54 -04:00
Gregory Bragg
1f666bcc49 Documentation For new SMB components
* Updated SMB Module documentation for new components
`SmbStreamingMessageSource` and `SmbOutboundGateway`
* Update based on PR review feedback
* Omit XML config examples based on PR review feedback
2022-05-24 10:12:41 -04:00
Artem Bilan
4cc9b300d4 The testWindowTimespan() is time-sensitive
The `FluxAggregatorMessageHandlerTests.testWindowTimespan()`
relies on the time-based window function of `100` millis.
Looks like a delay of `Thread.sleep(20)` may cause a resources race
condition and window is released only with one item.

* Disable `testWindowTimespan()` since there is no guarantee with what
timing settings it is going to work stably

**Cherry-pick to `5.5.x`**
2022-05-23 12:08:03 -04:00
Gregory Bragg
4203a2369f SmbOutboundGateway: Other remote file operations
* Enhanced SmbOutboundGateway with supported remote file operations
* Updated SmbOutboundGateway code based on PR review feedback
* Fully implemented listNames() in SmbSession, added more JUnit tests
* Updated SmbSession code based on PR review comments
2022-05-20 16:37:39 -04:00