Commit Graph

11289 Commits

Author SHA1 Message Date
abilan
f2b88b4c6a Fix sonar smell in the MessagingGatewaySupport 2023-03-17 14:52:41 -04:00
abilan
db90e68ca7 Fix Sonar and JaCoCo relationship
* Explicitly enable Jacoco XML report
Must be `xml.required = true`
* Starting with version 3 the Sonarqube Gradle plugin
does not do any automatic dependencies on other tasks:
https://docs.sonarqube.org/latest/analyzing-source-code/scanners/sonarscanner-for-gradle/
* It is also does not apply the task to sub-projects.
So, to make the root `sonarqube` task we need to have config like this:
```
 rootProject.tasks['sonarqube'].dependsOn jacocoTestReport
```
Note: the `sonarqube` task is deprecated in favor of `sonar`,
but that is exactly what our current Bamboo Sonar plugin does.
So, when that is upgraded, we need to revise our config again
* We don't need `xml.outputLocation` since its default is what Sonar expects
2023-03-17 14:45:52 -04:00
Lyam Hunt
8b99178227 Fix typo in README.md 2023-03-16 16:37:09 -04:00
Anton Gabov
d7150685b1 RedisLockRegistry: Don't expire not acquired lock
Fix race condition, when methods `RedisLockRegistry#expireUnusedOlderThan` and `RedisLockRegistry#obtain` are executed successively. 

It's possible to delete the lock from `RedisLockRegistry#expireUnusedOlderThan` method, when lock is created but is not acquired (`RedisLock#getLockedAt = 0`)
It can lead to the situation, when `RedisLockRegistry#obtain` returns multiple locks with the same redis-key, which shouldn't happen at all.

* Skip locks from expiration when their `lockedAt == 0` - new, not acquired yet.

**Cherry-pick to `6.0.x` & `5.5.x`**
2023-03-15 11:18:03 -04:00
Artem Bilan
8fbf75f42c Some LockRegistryLeaderInitiator improvements (#8570)
* Some `LockRegistryLeaderInitiator` improvements

It is better to not go to the target lock provider at all
if the current thread is already interrupted.

* Check for the `Thread.currentThread().isInterrupted()` in the `while` loop
and `restartSelectorBecauseOfError()` immediately without checking for a lock
* Fix some other simple typos in the `LockRegistryLeaderInitiator`

**Cherry-pick to `6.0.x`**

* * Introduce a `LeaderSelector.yielding` flag
to revoke leader smoothly.
Turns out just canceling the `Future` may lead to a broken lock
where we cannot unlock it because the target lock repository may not work
with interrupted threads.
This way a new leader must wait until the lock is expired in the store
2023-03-15 10:10:02 -04:00
abilan
65271fc935 Fix Checkstyle for leading whitespaces 2023-03-07 12:09:49 -05:00
abilan
f0d21040b8 Fix new Sonar smells 2023-03-07 12:01:42 -05:00
abilan
f128a3f2eb Use sonar instead of deprecated sonarqube 2023-03-07 10:01:01 -05:00
abilan
1022d94dec Upgrade to Sonar 4.0.0.2929 2023-03-07 09:47:30 -05:00
abilan
4cbd22b583 Gradle 8.0.2, Dokka 1.8.10, Checkstyle 10.8.0 2023-03-06 09:23:03 -05:00
Chris Bono
3fad7cd96b Reduce instance supplier use to appease AOT
* Remove the use of instance suppliers on bean definitions
that are processed during the AOT phase.

* The remaining areas that use instance suppliers do so
at runtime and do not use reflection, but instead
are passed the configured bean to register.

See https://github.com/spring-cloud/spring-cloud-stream/issues/2655

**Cherry-pick to `6.0.x`**
2023-03-02 19:00:25 -05:00
Artem Bilan
dfe45c7c29 GH-8559: Document how to enable SOCKS for SFTP (#8565)
* GH-8559: Document how to enable SOCKS for SFTP

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

An out-of-the-box `SshClient` does not provide a smooth HTTP/SOCKS proxy configuration.

* Mention in the `sftp.adoc` that `JGitSshClient`, configured with SOCKS,
can be injected into a `DefaultSftpSessionFactory`
* Fix Javadocs for `DefaultSftpSessionFactory`, respectively

* Fix language in doc

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

---------

Co-authored-by: Gary Russell <grussell@vmware.com>
2023-02-28 17:33:31 -05:00
abilan
38f19348cf Upgrade to rome-2.0.0; fix deprecation
* Fix `FeedInboundChannelAdapterParser` to properly populate a `Resource` ctor arg
2023-02-28 16:48:30 -05:00
Artem Bilan
ce9f7f4321 GH-8562: Fix streaming source for remote calls (#8564)
* GH-8562: Fix streaming source for remote calls

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

The `AbstractRemoteFileStreamingMessageSource.doReceive()` takes files first from a `toBeReceived` queue.
When `AbstractRemoteFileStreamingMessageSource.remoteFileToMessage()` fails to fetch the file content
because of interim connection issue, we reset this file from a filter and rethrow an exception.
The next `receive()` call will just go ahead to the next entry in the `toBeReceived` queue, but the
file we have just failed for will be retried only on the next list call to the remove directory.
This essentially breaks a possible in-order target application logic.

* Introduce `AbstractRemoteFileStreamingMessageSource.strictOrder` option to clear the `toBeReceived` queue
 when we fail in the `remoteFileToMessage()`, so the next `receive()`
 call would re-fetch files from remote dir, because the filter has been reset for those files.
* Fix `AbstractFileInfo.toString()` to not perform remote calls when we just log this file.
For example, we reset the file for connection failure and log the message about it,
but it fails again because we request `size` of the file which may require a remote connection.

**Cherry-pick to `6.0.x` & `5.5.x`**

* * Revert `AbstractFileInfo` changes
* Override `toString()` in `SmbFileInfo` instead -
exactly the place where connection is used to obtain
file attributes like `size` or `lastModified`
2023-02-28 16:34:19 -05:00
Spring Builds
a09d6dcd2c [artifactory-release] Next development version 2023-02-22 22:41:07 +00:00
Spring Builds
6705f46705 [artifactory-release] Release version 6.1.0-M1 2023-02-22 22:41:04 +00:00
abilan
ea4d185da9 Remove redundant build config for Kotlin 2023-02-22 16:39:12 -05:00
Christian Tzolov
451374dd11 GH-3772 Add Protobuf transformation support
Fixes https://github.com/spring-projects/spring-integration/issues/3772

* Add basic To/From Protocol Buffer's com.google.protobuf.Message transformers.
* Allow the proto_type header to specify the type.
* Add tests.
* add Protobuf docs
* Leverage the Spring ProtobufMessageConverter
* move protobuf-java-util to test dependecies as optional
* protobuf docs improvements
* improve the expected type handling
* expected type expression
* fix indentation
* fix indentation for generated test classes
* suppress style check for proto generated classes
* address the transformer doc format
* fix whats new merge conflict
* fix doc sample code
* Some code clean up; fixing typos
2023-02-22 16:23:49 -05:00
Artem Bilan
acd8a03d4d GH-3957: Add JmsInboundGateway.replyToExpression (#8560)
* GH-3957: Add JmsInboundGateway.replyToExpression

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

Sometimes we cannot use a standard `JmsReplyTo` property for sending replies from the server.
A `DestinationResolver` API does not have access to the request message.

* Introduce a `ChannelPublishingJmsMessageListener.replyToExpression` property to evaluate
a reply destination against request JMS `Message`
* Use this expression only of no `JmsReplyTo` property
* Expose this property on Java DSL level
* To simplify end-user experience with lambda configuration for this property, introduce a `CheckedFunction`
which essentially re-throws exception "sneaky" way

* Fix Javadoc for `CheckedFunction`

* * Fix language in docs
* Fix Javadocs lines length
* Regular `catch` and re-throw in the `CheckedFunction`
2023-02-22 15:23:13 -05:00
abilan
3f99424d93 Fix connection race condition in MQTT test
It looks like `isConnected` flag in the MQTT Client is reset when we already
have subscribed
2023-02-22 14:16:16 -05:00
Artem Bilan
fe9b59ea01 GH-3813: ClientWebSocketContainer URI setting (#8561)
* GH-3813: ClientWebSocketContainer URI setting

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

Introduce a `ClientWebSocketContainer(WebSocketClient client, URI uri)` ctor
to let end-user to decide what and how should be encoded the URI for WebSocket connection

* Fix language in docs

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

---------

Co-authored-by: Gary Russell <grussell@vmware.com>
2023-02-22 14:05:53 -05:00
abilan
86b4ad5258 Fix new Sonar smells
**Cherry-pick to `6.0.x`**
2023-02-22 12:39:02 -05:00
abilan
c8e171c0cd GH-3968: public IntObjSupp.setConversionService
Fixes https://github.com/spring-projects/spring-integration/issues/3968

The `IntegrationObjectSupport.setConversionService()` is protected by accident
2023-02-22 10:37:31 -05:00
abilan
ca7736d2a6 Fix race condition in AsyncMessagingTemplateTests 2023-02-22 10:14:32 -05:00
abilan
42b11d2d0a Fix HTTPS violation in the ZipTransformer 2023-02-21 17:21:18 -05:00
abilan
bea8c88d27 Downgrade to Gradle 7.6: Dokka plugin isn't ready 2023-02-21 17:12:28 -05:00
abilan
2884bf0135 Various upgrades for version 6.1
* Upgrade to Gradle `8.0.1`
* Upgrade to Kotlin `1.8`
* Some other libs updates
* Resolve some compatible TODOs
2023-02-21 16:50:01 -05:00
abilan
7d0265845a GH-4007: Remove MQTT ConsumerStopAction
Fixes https://github.com/spring-projects/spring-integration/issues/4007

It was deprecated in the previous version and fully covered with existing `cleanSession` connection option.
2023-02-21 15:18:06 -05:00
abilan
53d1ecd208 Upgrade to the latest Micrometer dependencies 2023-02-21 15:18:05 -05:00
abilan
210a2f9d2c Migrate Zip Extension as a core module 2023-02-21 15:18:05 -05:00
abilan
39c73d404a Start version 6.1
* Upgrade dependencies whenever it is reasonable
* Fix deprecations and some new API paths
* Move docs to a new version with respective branching for the `changes-5.5-6.0.adoc`
2023-02-21 15:18:03 -05:00
Spring Builds
ab32591012 [artifactory-release] Next development version 2023-02-21 19:31:05 +00:00
Spring Builds
7592c64073 [artifactory-release] Release version 6.0.3 2023-02-21 19:31:02 +00:00
abilan
ee5ea036cc Fix deprecations from upstream dependencies 2023-02-21 13:47:15 -05:00
abilan
a8dd9188c1 Upgrade dependencies; prepare for release 2023-02-21 13:14:40 -05:00
Artem Bilan
ee2b6b4098 Fix MQTT Inbound readyToSubscribeOnStart logic (#8557)
We cannot always reset `readyToSubscribeOnStart` to `false` in the `stop()`
since we may be connected to `ClientManager` and have `cleanStart` option,
so we `unsubscribe()` in the stop and then when we start there is no way to subscribe back

* Reset `readyToSubscribeOnStart` in the `AbstractMqttMessageDrivenChannelAdapter.doStop()`
only if we don't unsubscribe for a `cleanSession` reason.
* Also reset it in the `connectionLost`, so next `connectComplete` will take care about subscription
or `readyToSubscribeOnStart` state change
* Use `isActive()` instead of `isRunning()` in the `connectComplete()` since there is a race
condition when connection is established but `doStart()` has not returned yet, but already passed
`if (this.readyToSubscribeOnStart)` line
2023-02-21 12:57:30 -05:00
Artem Bilan
ac577e9ef7 Optional io.micrometer:context-propagation (#8556)
For better performance by default it is better to not pull
a `io.micrometer:context-propagation` a hard dependency.

* Remove `io.micrometer:context-propagation` dependency management
* It is pulled transitively by the `io.micrometer:micrometer-tracing-integration-test` in test scope
* Rework all the `ContextSnapshot` usage in the reactive code to respective recommended `handle()` API in `Flux` and `Mono`
2023-02-21 12:02:15 -05:00
Artem Bilan
b482b002cb GH-4014: MQTT ClientManager: completion timeouts (#8552)
Fixes https://github.com/spring-projects/spring-integration/issues/4014

The `ClientManager` implementations uses by mistake a `connectionTimeout` for operations with completion wait

* Introduce `completionTimeout` and `disconnectCompletionTimeout` for `ClientManager`
abstraction to realign the logic with existing channel adapters and Paho Client by itself.
* Deprecate `DEFAULT_COMPLETION_TIMEOUT` and `DISCONNECT_COMPLETION_TIMEOUT` constants
in the `AbstractMqttMessageDrivenChannelAdapter` in favor of respective replacement in the `ClientManager`
* Pull `disconnectCompletionTimeout` property from the `MqttPahoMessageDrivenChannelAdapter` to its superclass
* Use new `disconnectCompletionTimeout` in the `Mqttv5PahoMessageDrivenChannelAdapter` for similar `disconnectForcibly()` call
* Fix Lifecycle race condition when `ClientManager` is started by the outbound channel adapter
(`Integer.MIN_VALUE` phase and auto-startup - see `DefaultLifecycleProcessor.doStart()` and logic around `dependencies`)
which is much earlier than `MessageProducerSupport` (`Integer.MAX_VALUE / 2` phase) and there a `connectComplete()` callback
might be called before the `MessageProducerSupport.start()`.
For that purpose check for an `isRunning()` in the `connectComplete()` before subscribing and set `readyToSubscribeOnStart` flag
to `subscribe()` in a `doStart()` of this `MqttMessageDrivenChannelAdapter`
* Remove redundant `MqttPahoMessageDrivenChannelAdapter.cleanSession` property in favor of
`this.clientFactory.getConnectionOptions().isCleanSession()` call

GH-8550: MQTT: Always re-subscribe on re-connect

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

Turns out the Paho MQTT client does not re-subscribe when connection
re-established on automatic reconnection

* Fix `AbstractMqttMessageDrivenChannelAdapter` to always subscribe to their topics
in the `connectComplete()` independently of the `reconnect` status
* Verify behavior with `MOSQUITTO_CONTAINER` image restart in Docker
2023-02-15 17:26:12 -05:00
abilan
3d245276e4 Fix new Sonar smells 2023-02-14 17:02:23 -05:00
abilan
4cd1085f94 Upgrade some dependencies
* Remove already redundant `parentObservation` population in the `AbstractMessageChannel`:
now it is handled properly by the `SimpleObservation` ctor
2023-02-14 15:01:42 -05:00
Gary Russell
e8a9f95ca1 GH-4013: TCP DSL Improvements
Resolves https://github.com/spring-projects/spring-integration/issues/4013

Add Net/NIO specific Server/Client connection factory specs.

* Shorten DSL method names, as suggested.
2023-02-08 17:01:44 -05:00
Ivan Zaitsev
e6d0a4f826 GH-4008: ZK: Add leader and participants support
Fixes https://github.com/spring-projects/spring-integration/issues/4008

Impossible to retrieve current leader id from ZK `LeaderInitiator`

* change return type of `LeaderInitiator.getContext()` from `Context` to `CuratorContext`
* add `getLeader()` method to `CuratorContext`
* add `getParticipants()` method to `CuratorContext`
2023-02-07 10:36:29 -05:00
Artem Bilan
6a2ff0cd99 GH-4001: Doc for cooperation with some HZ objects (#4003)
* GH-4001: Doc for cooperation with some HZ objects

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

The `IQueue`, `ITopic` and `IExecutorService` can be used with Spring Integration
channel as is without any extra component implementations.

* Document the cooperation feature with Hazelcast objects via samples

* * Add a sample about an Inbound Channel Adapter on the `IQueue`

* Fix language in docs

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

---------

Co-authored-by: Gary Russell <grussell@vmware.com>
2023-02-06 12:20:42 -05:00
Artem Bilan
44000b9606 GH-4002: Deprecate ConsumerStopAction in MQTT (#4006)
Fixes https://github.com/spring-projects/spring-integration/issues/4002

Turns out the `ConsumerStopAction` was introduced in a point version to mitigate an unsubscription bug
and let to preserve a previous behaviour.

* Deprecate `ConsumerStopAction` in favor of just `cleanSession` flag in the `MqttConnectOptions`

**Cherry-pick to `5.5.x`**
2023-02-06 11:58:41 -05:00
Artem Bilan
d9d7c49aac Propagate and Observation from Reactive context (#3999)
To propagate an `Observation` from reactive stream (e.g. WebFlux)
we have to capture its context and set it into the current thread scope.

* Add a `io.micrometer:context-propagation` dependency to support reactive context propagation
* Populate a `parentObservation` in the `IntegrationObservation.PRODUCER.observation()`
since it is not available for tracing on `Observation.onStart()`.
Might be tentative until upcoming fix in Micrometer Observation
* Populate from reactive context in the `WebFluxInboundEndpoint` where we use just `send()` operation downstream
* Populate from reactive context in the `MessagingGatewaySupport` where we use `send()` operation downstream or `FluxMessageChannel.subscribeTo()`
* Use `contextCapture()` in the `FluxMessageChannel` to gather a `ThreadLocal` info into a Reactor context
and then set back to `ThreadLocal` in the `transformDeferredContextual()` which really happens on a different thread
* Verify a trace propagation from WebFlux to an integration flow via Brave instrumentation in the `WebFluxObservationPropagationTests`
2023-02-01 14:13:40 -05:00
Artem Bilan
841289002c GH-3998: Fix gateway docs for @Payload (#4000)
* GH-3998: Fix gateway docs for `@Payload`

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

The `GatewayProxyFactoryBean` now deals only with a `MethodArgsHolder` as a root evaluation context object.
There is no `#args` and `#method` SpEL variables anymore.
However, the `gateway.adoc` still refer to those.

* Fix `gateway.adoc` for a proper expressions and actual wording

* * Cross link to `gateway-expressions` paragraph for better context
2023-02-01 14:05:20 -05:00
Artem Bilan
f01e2b8553 GH-3994: Register native hints for Graph model (#3996)
Fixes https://github.com/spring-projects/spring-integration/issues/3994

Essentially, migrate those hints from Spring Boot Actuator:
an `IntegrationGraphServer` can be used without Spring Boot

* Introduce `IntegrationGraphRuntimeHints` - implementation of `RuntimeHintsRegistrar`
to register reflection hints for `Graph` and top-level `IntegrationNode` types.
* Use `@ImportRuntimeHints` on the `IntegrationGraphServer` to make those hints
conditional.
2023-01-23 14:22:42 -05:00
Artem Bilan
ebba37497f GH-3993: Fix async race condition in TcpOutGateway (#3995)
* GH-3993: Fix async race condition in TcpOutGateway

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

When `TcpOutboundGateway` is in an `async` mode and `CCF` is configured
not for `singleUse` an `Semaphore` around an obtained `TcpConnection` is involved.
If we fail on `TcpConnection.send()`, resources are not clean up, including the
mentioned `Semaphore`: in async mode this happens only when we receive a reply.

* Catch an exception on the `TcpConnection.send()` and perform `cleanUp()` in async mode.
* Add `cleanUp()` into a scheduled task from the `TcpOutboundGateway.AsyncReply`
when no reply arrives in time.
* Optimize `TcpOutboundGateway.AsyncReply` behavior to cancel no-reply scheduled task
when reply arrives into a `CompletableFuture`

**Cherry-pick to `5.5.x`**

* * Call `cleanUp()` from no response scheduled task
only if `future.completeExceptionally()` is `true`
2023-01-23 11:07:19 -05:00
Spring Builds
f8c0779964 [artifactory-release] Next development version 2023-01-18 18:20:29 +00:00
Spring Builds
480a9735bf [artifactory-release] Release version 6.0.2 2023-01-18 18:20:26 +00:00