Looks like `ApplicaitonContext.stop()` is note called on `close()`.
This might cause an `OutOfMemoryError` on the CI
* Use Spring context configuration for the test environment
Fixes: #9335
Spring Boot provides a `CompositeMeterRegistry` bean marked with a `@Primary`.
So, this one has to be autowired whenever we would like to deal with application
environment.
The `MicrometerNodeEnhancer` has a flaw to skip `MeterRegistry` injection if we have more than one `MeterRegistry` bean.
* Fix `MicrometerNodeEnhancer` logic to use `ObjectProvider.getIfUnique()` API
which is able to deal with the `primary` properly.
Otherwise, `null` as it was before
**Auto-cherry-pick to `6.3.x` & `6.2.x`**
If we don't get access to `BeanFactory` in exclusive mode,
the `getBean(Class<?>)` may fail with a `BeanCurrentlyInCreationException`
when we register several `IntegrationFlow` instances in parallel
* GH-9294: Set permissions to target file on rename
Fixes: #9294
When the `deleteSourceFiles` property of `FileWritingMessageHandler` is `true`, the `chmod` is not set on the target file.
* Fix `FileWritingMessageHandler.handleFileMessage()` logic to `setPermissions(resultFile)` after `move` operation
**Auto-cherry-pick to `6.3.x` & `6.2.x`**
* * Set only `OWNER_READ` permission for file in unit test
Fixes: #9291
* Modify `unlock()` method of `JdbcLock`: if the lock ownership can not be removed due to data expiration, a `ConcurrentModificationException` should be thrown.
* Modify `unlock()` method of `RedisLock`: if the lock ownership can not be removed due to data expiration, a `ConcurrentModificationException` should be thrown.
* Maintain test cases
* Document the new behavior
Fixes: #9297
For a normal `jakarta.mail.StoreClosedException: * BYE Jakarta Mail Exception: java.net.SocketException: Connection reset`
the `ImapIdleChannelAdapter.callIdle()` results in a resubmission (and reconnection)
with logging 'Failed to execute IDLE task. Will attempt to resubmit in 10000 milliseconds.'`
However, when `selectorExpression` is in used and that one is based on mail `Message` object,
we may fail with `FolderClosedException` which is wrapped to the `SpelEvaluationException` and some
other stack traces.
So, `jakarta.mail.MessagingException` might be deep in the cause chain.
* Fix `ImapIdleChannelAdapter` via introducing `getJakartaMailMessagingExceptionFromCause()` utility
method which searches for the `jakarta.mail.MessagingException` in cause chain.
* Rework `ImapIdleChannelAdapter.callIdle()` logic to rely on this new method
**Auto-cherry-pick to `6.3.x` & `6.2.x`**
Fixes: #9272
* close ClientSession when closing SftpSession
* fix whitespace issues
* stop the SshClient on bean destruction
* use convenient assertions
**Auto-cherry-pick to `6.3.x` & `6.2.x`**
Fixes: #9228
* add docs
* protected constructor in ZeroMqMessageHandlerSpec, expose them via ZeroMq
* introduce ZeroMqUtils, for common Zero MQ utilities functions
* use ZeroMqUtils.bindSocket in ZeroMqMessageProducer
* refactor ZeroMqMessageHandler providing connectUrl and bindPort setters and simple constructors, following the same logic used for ZeroMqMessageProvider
* fix tests to follow the new ZeroMqMessageHandler implementation
* fix typo
* add new updates to whats-new.adoc
* address ZeroMQUtils comments
* remove connectUrl and boundPort setters, add Javadoc to new constructors
* add new DLS constructor for random port
* add since closure in ZeroMqUtils
* add DSL support methods and specific that, when not defined, the socket will be bound to a random port
Connection timeout's unit is specified as `seconds` in the annotation, but `soTimeout` unit is not specified as `milliseconds`, so people who do not know the parameter information of the java socket library may be confused.
Fixes: #9259
The `Mono.toFuture()` does not propagate context to thread locals of the `CompletableFuture` consumer.
See `MonoToCompletableFuture`
* Fix `AbstractMessageProducingHandler` to convert reply `Mono` to `CompletableFuture` manually.
Use `doOnEach()` and set thread locals from the Reactor context manually around `replyFuture.complete()/completeExceptionally()`
* Add respective unit test into `WebFluxObservationPropagationTests` to ensure that same trace is used in downstream endpoints after WebFlux client reply
**Auto-cherry-pick to `6.3.x` & `6.2.x`**
Fixes: #9276
The current Eclipse Paho client has wrong removal from map logic which leads to the
`ConcurrentModificationException` when we unsubscribe from topic.
* Catch a `ConcurrentModificationException` `this.mqttClient.unsubscribe()` and just log it as an `error`
**Auto-cherry-pick to `6.3.x` & `6.2.x`**
Fixes: #9260
The current `IntegrationManagementConfiguration.obtainObservationPatterns()` is to always have an `*` as a first
pattern in the final result.
Because of `HashSet` natural order.
This would lead to ignore all the patterns, especially those with negation
* Fix `IntegrationManagementConfiguration.obtainObservationPatterns()` logic to ignore regular
patterns if `*` is present.
Optimization wise.
* Always put `*` into the end of final array let negative patterns to do their job
* Modify `IntegrationGraphServerTests` & `WebFluxObservationPropagationTests`
test configurations to ensure that `*` pattern does not have a precedence over negative patterns.
**Auto-cherry-pick to `6.3.x` & `6.2.x`**
The `Sinks.Many<Boolean> subscribedSignal` is a bit of overhead in the logic.
* Use `Mono.fromCallable(this.sink::currentSubscriberCount)` instead for `delaySubscription()`
when we perform `subscribeTo(Publisher)`
**Auto-cherry-pick to `6.3.x` & `6.2.x`**
Fixes: #9268
The new `SmbSession.list()` behavior prevents to pull files from sub-folders in inbound channel adapter
* Fix `SmbSession.list()` similar way to `SftpSession`: if `remoteFile.isFile()` then remove it as is.
Otherwise, perform `smbDir.listFiles()` on that sub-dir
* Modify `SmbTests.testSmbInboundFlow()` to poll files from the `smbSource/subSmbSource/`
**Auto-cherry-pick to `6.3.x` & `6.2.x`**
Fixes: #9191
Not all inbound protocol handlers convert header from native representation.
Sometimes they just come in as `byte[]`.
* Fix `MessageReceiverContext` to support `byte[]` for headers used in the observation,
e.g. `B3-*`, `traceparent` etc.
**Auto-cherry-pick to `6.3.x` & `6.2.x`**
Fixes: #9214
The `MqttAsyncClient` can set `subscriptionIdentifier` from session if it is enabled
and available from connection
* Remove manual `subscriptionIdentifierCounter` from the `Mqttv5PahoMessageDrivenChannelAdapter`.
Instead, use `subscriptionProperties.setSubscriptionIdentifiers(List.of(0));`
to make the `this.mqttSession.getNextSubscriptionIdentifier();` to work
when `if (connOpts.useSubscriptionIdentifiers() && this.mqttConnection.isSubscriptionIdentifiersAvailable()) {` is `true`
**Auto-cherry-pick to `6.3.x` & `6.2.x`**
Fixes: #9215
* Instead of `share()` use `publish(1).refCount()` to prefetch only item from upstream.
* Also remove `publishOn(this.scheduler)` for upstream publishers in favor of opt-in on the consumer side.
**Auto-cherry-pick to `6.3.x` & `6.2.x`**
Fixes: #9211
The `AbstractRemoteFileOutboundGateway.get()` uses `Session.list()` for the provided remote file name.
The `SmbSession` does not support listing for a single file.
* Add logic into `SmbSession.list()` similar to `SftpSession.list()` to list a single remote file
on the provided path
**Auto-cherry-pick to `6.3.x` & `6.2.x`**