Commit Graph

11437 Commits

Author SHA1 Message Date
Artem Bilan
0f402ca2e6 GH-8852: Fix TcpNetServerConnectionFactory.run loop
Fixes: #8852

The `while (true) {` causes the thread to be blocked forever.
The `stop()` waits on the `if (!executorService.awaitTermination(10, TimeUnit.SECONDS)) {` the whole time

* Fix with the `while (isActive()) {`
* Remove the `ConnectionFactoryTests.testEarlyCloseNet()` since we cannot reach expectations because of
race condition between `start()` and `stop()`

**Cherry-pick to `6.2.x` & `6.1.x`**

(cherry picked from commit 0b60dfc9d1)
2024-01-05 15:54:44 -05:00
Artem Bilan
383361a32a Migrate GHAs for repo from Spring IO org
**Cherry-pick to `6.1.x`**

(cherry picked from commit 075613c4a1)
2023-12-20 17:05:01 -05:00
Roman Zabaluev
ec707e71fa GH-8803: RedisLockRegistry: Log for lock acquired
Fixes: #8803

Would be great to have an `Acquired lock; RedisLock...`  logging message as we already have `Released lock; RedisLock ...`

* Improve `RedisLockRegistry.RedisLock.tryRedisLock()` to emit `Acquired lock; RedisLock...` debug message

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

(cherry picked from commit 9bd8001a61)
2023-12-11 17:07:00 -05:00
Artem Bilan
8c18dc553a Rework verify staging WF for Gradle init script
* Fix verify staging WF without JFrog
* Use `ARTIFACTORY` secrets for `libs-staging-local`

**Cherry-pick to `6.1.x`**
2023-12-07 18:04:36 -05:00
Artem Bilan
ff57907efc Add new line in the end of FileTailMessProdTests
**Cherry-pick to `6.1.x`**

(cherry picked from commit 940ec888f7)
2023-12-06 13:27:52 -05:00
Artem Bilan
5beb1bd9d2 Remove unused imports from FileTailMessProdTests
The Checkstyle violation for unused imports in the `FileTailingMessageProducerTests`
Leftover from the previous fix for this class

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

(cherry picked from commit a6f826e1cf)
2023-12-06 13:12:30 -05:00
Artem Bilan
961d769f09 Add backport-issue.yml GHA workflow
(cherry picked from commit 6d2bf330d1)
2023-12-06 12:57:28 -05:00
Artem Bilan
1151cc7c32 Fix FileTailingMessProducerTests for tail events
The `OSDelegatingFileTailingMessageProducer` publishes event from scheduled task

* Modify `FileTailingMessageProducerTests.testGuts()` to use `CountDownLatch`
to wait for those asynchronous events

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

(cherry picked from commit a3d347eddd)
2023-12-06 12:56:52 -05:00
Artem Bilan
0531832a0e GH-8800: Fix SMB Gateway for recursive MGET
Fixes: gh-8800

The `SmbFile.getName()` returns plain file name, not with a
sub-directory as it is expected by the `AbstractRemoteFileOutboundGateway`
for (S)FTP protocols

* Introduce `AbstractRemoteFileOutboundGateway.getFullFileName()`
with dir and file name concatenation by default (as it was before)
and override it in the `SmbOutboundGateway` to return the full path according this protocol.
* Fix `SmbOutboundGateway.enhanceNameWithSubDirectory()` to return an `SmbFile` instance
since it has all the info about remote file, include requested directory
* Fix `SmbOutboundGateway.getFilename()` to remove the trailing `/` in the dir name
since this is not what expected by the `AbstractRemoteFileOutboundGateway` logic

**Cherry-pick to `6.1.x`**
2023-12-06 18:06:40 +01:00
Artem Bilan
45a32cf13c Add explicit ref to verify-staged-artifacts.yml
**Cherry-pick to `6.1.x`**

(cherry picked from commit 9f7acd7d9d)
2023-12-01 17:35:23 -05:00
Artem Bilan
0d85f2a464 Migrate CI/CD to GitHub Actions
* Remove JFrog plugin since it is supplied from CI/CD by Gradle init script
* Remove Sonar and Jacoco since we don't manage those service anymore

# Conflicts:
#	.github/release-files-spec.json
#	.github/workflows/central-sync-close.yml
#	.github/workflows/central-sync-create.yml
#	.github/workflows/central-sync-release.yml
#	.github/workflows/ci-snapshot.yml
#	.github/workflows/pr-build-workflow.yml
#	build.gradle
2023-12-01 17:15:57 -05:00
Spring Builds
b4dd400d13 [artifactory-release] Next development version 2023-11-21 19:58:46 +00:00
Spring Builds
590d701fa3 [artifactory-release] Release version 6.1.5 2023-11-21 19:58:43 +00:00
Artem Bilan
ed1bfc6d45 Upgrade to Spring GraphQL 1.2.4 2023-11-21 13:26:26 -05:00
Artem Bilan
c4e30a0b54 Revert to SSHD 2.9.2
The Apache `sshd-core-2.9.3` has some breaking changing for path resolution in Linux
2023-11-20 17:10:26 -05:00
Artem Bilan
5cb99d32e7 Fix Spring Data version 2023-11-20 15:56:54 -05:00
Artem Bilan
fb913e194f Upgrade dependencies; prepare for release 2023-11-20 15:47:57 -05:00
Artem Bilan
5d93c6ae6c GH-8792: Fix File StreamingMS for one file filter
Fixes https://github.com/spring-projects/spring-integration/issues/8792

1. Use a `SftpStreamingMessageSource` with a `maxFetchSize = 5` and a `ChainFileListFilter` filter composed with
`SftpSystemMarkerFilePresentFileListFilter` which `supportsSingleFileFiltering == false`
2. Put 2 files in the folder and invoke `SftpStreamingMessageSource.receive()` method twice.
3. Put 5 files in the folder and invoke `SftpStreamingMessageSource.receive()`` method five times.
4. The last two files won't be received.

When you set max fetch size to a number bigger than one (for example 5) and at a certain point
it is necessary to `this.toBeReceived.clear()` inside `AbstractRemoteFileStreamingMessageSource.doReceive()`,
those removed elements from toBeReceived are not rolled back.

* Fix `AbstractRemoteFileStreamingMessageSource.listFiles()` to calculate `maxFetchSize` as `getMaxFetchSize() - this.fetched.get()`

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

(cherry picked from commit 22c4db291b)
2023-11-17 16:40:02 -05:00
Gary Russell
ef2575a751 Increase Timeouts in FTP RotatingServersTests
Some unknown delays on MacOS cause the tests to fail.
2023-11-14 09:25:58 +01:00
Artem Bilan
9227acd732 GH-8786: Make FtpSession.finalizeRaw() robust
Fixes https://github.com/spring-projects/spring-integration/issues/8786

If `FtpSession.readRaw()` fails, the next `FtpSession.finalizeRaw()` call
would lead to `FTPClient.completePendingCommand()` failure since
there is no command to finish.

* Fix `FtpSession.finalizeRaw()` to exit earlier positively in case of
`FTPReply.isNegativePermanent()` for the current reply code set by the failure
from a previous `FtpSession.readRaw()`

**Cherry-pick to `6.1.x`, `6.0.x` & `5.5.x`**
2023-11-14 09:10:22 +01:00
Artem Bilan
59df2b9110 GH-8785: Propagate WebSocket client connect fail
Fixes https://github.com/spring-projects/spring-integration/issues/8785

The `ClientWebSocketContainer.start()` delegates to the `IntegrationWebSocketConnectionManager`
which performs an async connection to the server.

* Wait for `connectionLatch` in the `ClientWebSocketContainer.start()`
and check for `this.openConnectionException != null` to re-throw.
Mark `ClientWebSocketContainer` as stopped in that case

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

# Conflicts:
#	spring-integration-websocket/src/main/java/org/springframework/integration/websocket/ClientWebSocketContainer.java
2023-11-09 10:30:12 -05:00
Artem Bilan
72ce758593 Fix KV store for group-to-message relationship
The `this.messagePrefix + groupId + '_' + messageId` logic
is introduced since `6.2` via: 64f8ed5bab

The current fix for new `getMessageFromGroup()` and `removeMessageFromGroupById()`
is to retrieve group and then perform plain `get` and `delete` against just message id

Related to: https://github.com/spring-projects/spring-integration/issues/8773
2023-11-03 17:09:37 -04:00
Artem Bilan
cf5427f87d GH-8773: Fix MGS for removal from group
Fixes https://github.com/spring-projects/spring-integration/issues/8773

The https://github.com/spring-projects/spring-integration/issues/8732 introduced a filtering for messages in group.
So, plain `removeMessage()` doesn't work any more if message is connected to some group yet.
Therefore, `DelayHandler` is failing.

* Introduce `getMessageFromGroup()` and `removeMessageFromGroupById()` into `MessageGroupStore` API
and implement it respectively in all the stores
* Remove `@LongRunningTest` from delayer integration tests and adjust its config to delay not for a long

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

# Conflicts:
#	spring-integration-core/src/main/java/org/springframework/integration/handler/DelayHandler.java
2023-11-03 16:39:28 -04:00
Artem Bilan
8cdead4a44 GH-8778: Fix KafkaMessageSource deadlock (#8780)
* GH-8778: Fix KafkaMessageSource deadlock

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

The `KafkaMessageSource.doReceive()` have a lock around its whole body.
That includes the `pollRecord()` which can be blocked on the `KafkaConsumer.poll()`.
This way the rest of lifecycle management callbacks can be blocked until `KafkaConsumer.poll()` returns.

* Rework lifecycle management flags to `AtomicBoolean` since there is not too much work
in their respective callbacks
* Decrease a locking block in the `doReceive()` just to consumer setup part.
Leave `pollRecord()` outside of the lock
* Add `this.consumer.wakeup()` into `stopConsumer()` to break a `poll()` cycle
and return immediately for the next `close()` call

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

* * Use `compareAndSet` in `start` & `stop`
2023-10-26 15:34:04 -04:00
Artem Bilan
6ec2b88e1b GH-8779: MongoDbMS Fix distinct result conversion (#8781)
Fixes https://github.com/spring-projects/spring-integration/issues/8779

The `MongoTemplate` has now a `findDistinct()` API with a smart
result conversion instead of native driver plain expectations

**Cherry-pick to `6.1.x` & `6.0.x`**
2023-10-26 15:29:30 -04:00
Artem Bilan
991d29eb15 KafkaMessageSource: Lock instead of synchronized
Related to https://github.com/spring-projects/spring-integration/issues/8778

**Cherry-pick to `6.0.x`**
2023-10-26 13:28:40 -04:00
Artem Bilan
91e806afc5 GH-8770: Add PostgresSubsChannel.errorHandler (#8777)
* GH-8770: Add `PostgresSubsChannel.errorHandler`

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

The problem with the `PostgresSubscribableChannel.notifyUpdate()` is that the try-catch block is outside the loop,
so the loop will die on an exception, leaving further messages unprocessed.

* Add ``PostgresSubscribableChannel.errorHandler` option to be invoked
after a `RetryTemplate` and for every failed message.
* The `askForMessage()` new logic is to catch an exception on a message and call `errorHandler`
returning a `FALLBACK_STUB` to continue an outer loop in the `notifyUpdate()`

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

* * Rename private `PostgresSubscribableChannel.askForMessage()` method to more specific `pollAndDispatchMessage()`
2023-10-25 13:28:37 -04:00
Artem Bilan
4907316c4d Fix PostgresSubscribableChannel race condition
The `PostgresSubscribableChannel` uses a task executor
for dispatching messages.
Even if we stop `PostgresChannelMessageTableSubscriber` and
unsubscribe from the channel, the task might be ongoing.

* Use explicit `ThreadPoolTaskExecutor` in the test
to shout it down and wait for tasks to be completed before
verifying DB status
* Optimize `PostgresSubscribableChannel` to mark TX for rollback
when we got a message from DB, but no handlers subscribed

# Conflicts:
#	spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/channel/PostgresChannelMessageTableSubscriberTests.java
2023-10-25 09:56:21 -04:00
Spring Builds
7c2e8c47ec [artifactory-release] Next development version 2023-10-17 15:21:02 +00:00
Spring Builds
db3249a310 [artifactory-release] Release version 6.1.4 2023-10-17 15:20:53 +00:00
Artem Bilan
3fc372b68e Update dependencies; prepare for release
* Adapt AMQP module for the latest Spring AMQP changes
2023-10-17 10:09:11 -04:00
Christian Tzolov
68f977a588 Streamline UUIDConverter
* Use `StandardCharsets.UTF_8` as a charset configuration instead of string.
   Later remove the necessity of handling encoder errors.
* Use regular expressions to validate the `UUID` string standard representation.
   Later obsolete the need for try/catch exceptions.
* Deprecate `UUIDConverter.DEFAULT_CHARSET` since it is out of use.

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

Code clean up for `UUIDConverter`
2023-10-16 14:14:29 -04:00
Johannes Edmeier
00d8f671e5 Reduce log noise for AbstractCorrelatingMH
We use an aggregate handler that uses a group timeout.
It's expected that this timeout will be hit frequently.
However, this causes a info log message emitted every time.
I'd propose to log this message on debug.

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

(cherry picked from commit f89ca99bde)
2023-10-16 11:05:44 -04:00
Artem Bilan
274a3e0028 GH-8745: Add RFT.shouldMarkSessionAsDirty() (#8759)
* GH-8745: Add RFT.shouldMarkSessionAsDirty()

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

Not all errors caught in the `RemoteFileTemplate.execute()`
are fatal to mark session as dirty and physically close the target session
in the cache

* Introduce a `RemoteFileTemplate.shouldMarkSessionAsDirty()`
to consult with an exception if it is really a fatal error to close
the session in the end.
* Override `shouldMarkSessionAsDirty()` in the `RemoteFileTemplate`
implementations to check statuses of respective protocol errors

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

* * Fix tests for pool interaction

* * Fix language in Javadocs
* Add more `not dirty` statuses to `SftpRemoteFileTemplate` & `SmbRemoteFileTemplate`
2023-10-11 11:00:38 -04:00
Falk Hanisch
b456fe63cb GH-8750: Add @Nullable to getRegistrationById()
Fixes https://github.com/spring-projects/spring-integration/issues/8750

* annotate `IntegrationFlowRegistration.getRegistrationById(String flowId)` with `@org.springframework.lang.Nullable`
* annotate `StandardIntegrationFlowContext.getRegistrationById(String flowId)` with `@org.springframework.lang.Nullable`

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

(cherry picked from commit 49cd14cb8a)
2023-10-10 13:47:24 -04:00
Falk Hanisch
56b63c7b33 GH-8754: MessageBuilder: enhance @Nullable
Fixes spring-projects/spring-integration#8754

* `AbstractIntegrationMessageBuilder.setExpirationDate(@Nullable Long expirationDate)`
* `MessageBuilder.setExpirationDate(@Nullable Long expirationDate)`
* `MessageBuilder.setExpirationDate(@Nullable Date expirationDate)`

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

(cherry picked from commit 75fcddac00)
2023-10-10 12:28:55 -04:00
Artem Bilan
5af7871998 GH-8748: JDBC locks: use READ_COMMITTED isolation (#8749)
Fixes https://github.com/spring-projects/spring-integration/issues/8748

The Oracle DB throws `ORA-08177: can't serialize access for this transaction`
when other transaction on the row has begun

* Change the isolation for `DefaultLockRepository.acquire()` transaction
to the `READ_COMMITTED` for what database automatically and silently
restarts the entire SQL statement, and no error occurs.
* Add `oracle` dependencies to JDBC module
* Introduce `OracleContainerTest` and implement it for `OracleLockRegistryTests`

**Cherry-pick to `6.1.x` & `6.0.x`**
2023-10-09 11:53:18 -04:00
Artem Bilan
8c146d562d Fix maxMessagesPerPoll for SourcePollingChAdapter (#8747)
* Fix maxMessagesPerPoll for SourcePollingChAdapter

The `AbstractMethodAnnotationPostProcessor` does not check
for `PollerMetadata.MAX_MESSAGES_UNBOUNDED` before setting
`maxMessagesPerPoll` into a `SourcePollingChannelAdapter`
which in this case must be `1`

Also fix `SourcePollingChannelAdapterFactoryBean` to not mutate
the provided `PollerMetadata` (which might be global default)
with a new `maxMessagesPerPoll`

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

* * Fix `this.` prefix in `SourcePollingChannelAdapterFactoryBean`
2023-10-04 11:50:05 -04:00
Artem Bilan
f0768cdf4a Upgrade to Hibernate 6.2.8.Final
It looks like in the latest Hibernate there is some fix
in the persistent context where provided entity is updated
by the values from DB.

* Fix failing tests
* Migrate affected test classes to JUnit 5

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

# Conflicts:
#	build.gradle
2023-09-19 17:04:31 -04:00
Spring Builds
dad680073c [artifactory-release] Next development version 2023-09-19 19:07:43 +00:00
Spring Builds
d381d9682a [artifactory-release] Release version 6.1.3 2023-09-19 19:07:39 +00:00
Artem Bilan
4faa2ea680 Revert Hibernate version to 6.2.6.Final
It looks like in the latest Hibernate there is some fix
in the persistent context where provided entity is updated by the values from
DB.

We are going to address those failing JPA tests post-release
2023-09-19 14:05:21 -04:00
Christian Tzolov
797e294266 Upgrade dependecies; prepare for release 2023-09-19 19:30:46 +02:00
Artem Bilan
80990af0d1 Fix JMS Inbound Endpoints for observation
The `JmsMessageDrivenEndpoint` delegates all the hard work to the
`ChannelPublishingJmsMessageListener`, but missed to propagate an `ObservationRegistry`
and other related options.
The `JmsInboundGateway` is worse: it delegated to the `JmsMessageDrivenEndpoint`

* Add `IntegrationObservation.HANDLER` observation to the `MessagingGatewaySupport.send()`
operation: used by the delegate in the `ChannelPublishingJmsMessageListener`
* Expose and propagate observation-related options from `JmsInboundGateway`
and `JmsMessageDrivenEndpoint`
* Expose `observationConvention()` option on the `MessagingGatewaySpec`
and `MessageProducerSpec`
* Remove unused imports
* Do not start a new `RECEIVER` observation if there is already `SERVER` one
* Fix `MessagingGatewaySupport` for `Observation.NOOP` check.
The parent process may still use `ObservationRegistry.NOOP` which sets
`Observation.NOOP` instance into the current context and thread local.

**Cherry-pick to `6.1.x` & `6.0.x`**
2023-09-19 18:05:26 +02:00
Artem Bilan
78b09ed610 GH-8713: Add support for custom SftpClient
Fixes https://github.com/spring-projects/spring-integration/issues/8713

* Introduce `DefaultSftpSessionFactory.createSftpClient()` factory method
which can be overridden for any custom `SftpClient` use-case
* Add changes to the docs
* Some code clean up

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

# Conflicts:
#	spring-integration-sftp/src/main/java/org/springframework/integration/sftp/session/DefaultSftpSessionFactory.java
#	src/reference/antora/modules/ROOT/pages/sftp/session-factory.adoc
#	src/reference/antora/modules/ROOT/pages/whats-new.adoc
2023-09-18 16:35:49 -04:00
Artem Bilan
5eda90bdf2 Fix ThreadSPropagationChInterceptor for stacking (#8735)
* Fix ThreadSPropagationChInterceptor for stacking

Related SO thread: https://stackoverflow.com/questions/77058188/multiple-threadstatepropagationchannelinterceptors-not-possible

The current `ThreadStatePropagationChannelInterceptor` logic is to wrap one
message to another (`MessageWithThreadState`), essentially stacking contexts.
The `postReceive()` logic is to unwrap a `MessageWithThreadState`,
therefore we deal with the latest pushed context which leads to the `ClassCastException`

* Rework `ThreadStatePropagationChannelInterceptor` logic to reuse existing `MessageWithThreadState`
and add the current context to its `stateQueue`.
Therefore, the `postReceive()` will `poll()` the oldest context which is, essentially,
the one populated by this interceptor before, according to the interceptors order
* Fix `AbstractMessageChannel.setInterceptors()` to not modify provided list of interceptors
* The new `ThreadStatePropagationChannelInterceptorTests` demonstrates the problem
described in that mentioned SO question and verifies that context are propagated
in the order they have been populated

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

* * Fix `ThreadStatePropagationChannelInterceptor` for publish-subscribe scenario.
Essentially, copy the state queue to a new decorated message
* Fix `BroadcastingDispatcher` to always decorate message, even if not `applySequence`

* * Fix unused import in the `BroadcastingDispatcher`

* * Fix unused import in the `ThreadStatePropagationChannelInterceptor`
2023-09-18 12:36:12 -04:00
Myeonghyeon-Lee
945c842e15 Fix Checkstyle violation in the JdbcLockRegistry
**Cherry-pick to `6.1.x` & `6.0.x`**

(cherry picked from commit 0f1304494f)
2023-09-18 10:59:54 -04:00
Myeonghyeon-Lee
f687438f04 GH-8730: Fix isAcquiredInThisProcess to use localLock
The `ExpirableLockRegistry.expireUnusedOlderThan()` uses a query to the target store by mistake.
The logic of this API is indeed about the local cache for those lock instances.
We cannot effect any other processes with this cache.
And even if we remove our local instance while it is locked in other process,
that doesn't mean that on the next `obtain()` call, when we got a fresh local instance, we will be able to acquire a lock in target store.

* Fix `isAcquiredInThisProcess()` to check only `localLock.isLocked()`

**Cherry-pick to `6.1.x` & `6.0.x`**
# Conflicts:
#	spring-integration-jdbc/src/main/java/org/springframework/integration/jdbc/lock/JdbcLockRegistry.java
2023-09-18 10:41:39 -04:00
Artem Bilan
a4cadc93cf Fix PostgresSubscribableChannel.notifyUpdate()
When transaction is configured for the `PostgresSubscribableChannel.notifyUpdate()`
and it is rolled back, the next poll in that loop will return the same message.
Again and again if transaction is always rolled back.
This leads to the condition when we never leave this loop even if
we fully unsubscribed from this channel.

The issue has need spotted after introducing `SKIP LOCKED`
for `PostgresChannelMessageStoreQueryProvider` which leads to
the locked record in DB in the mentioned above transaction.

* Introduce `PostgresSubscribableChannel.hasHandlers` flag
to check in the `notifyUpdate()` before performing poll query in DB.

**Cherry-pick to `6.1.x` & `6.0.x`**
2023-09-18 14:31:39 +02:00
Artem Bilan
ccaa853d68 GH-8732 Don't remove JDBC message if other groups (#8733)
* GH-8732 Don't remove JDBC message if other groups

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

When same message is added into different groups,
its record in the `INT_MESSAGE` must remain until the last group is removed

* Improve `JdbcMessageStore.DELETE_MESSAGES_FROM_GROUP` SQL
to ignore those messages for removal which has other group records in the `INT_GROUP_TO_MESSAGE` table

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

* * Fix `JdbcMessageStore.removeMessage()` and `removeMessagesFromGroup()`
to remove from `INT_MESSAGE` only if there is no other records in `INT_GROUP_TO_MESSAGE`

* * Improve `MessageStore.removeMessage()` Javadoc
mentioning `MessageGroupStore` specifics
2023-09-14 12:58:41 -04:00