Commit Graph

10256 Commits

Author SHA1 Message Date
Gary Russell
e50209d045 GH-3648: Fix @Gateway.payloadExpression
Resolves https://github.com/spring-projects/spring-integration/issues/3648

When configuring a gateway proxy with XML, but specifying the payload expression
on the method `@Gateway` annotation, the expression was ignored, even though it
had been parsed.

`@Payload` worked.

With this change, if both `@Payload` and `@Gateway` are defined on a gateway method,
`@Gateway.payloadExpression` wins.

* Fix doc links.
# Conflicts:
#	src/reference/asciidoc/whats-new.adoc
2021-10-20 15:11:45 -04:00
Anthony Schweigard
4e6ce367d0 GH-3641: Handle duplicate cookies properly
Fixes https://github.com/spring-projects/spring-integration/issues/3641

When a duplicate cookie name appears in a request, an `IllegalStateException` is thrown.
The default `Collectors.toMap()` does not allow a duplicated keys.

* Handle `servletRequest.getCookies()` as a `MultiValueMap`
* Call `toSingleValueMap()` for the evaluation context variable to restore previous behavior.
The next major version must expose the `MultiValueMap` as is to give access to all cookies from end-user expressions
* Rework some HTTP tests to JUnit 5

**Cherry-pick to `5.4.x` & `5.3.x`**
2021-10-19 13:40:31 -04:00
Gary Russell
de06767c2e GH-3620: Fix Shared SFTP Session
Resolves https://github.com/spring-projects/spring-integration/issues/3620

Shared session field was captured outside of the lock, causing multiple sessions
in a multi-threaded environment.

**cherry-pick to 5.4.x, 5.3.x**
2021-08-30 10:52:09 -04:00
Spring Builds
708114c699 [artifactory-release] Next development version 2021-08-17 18:02:51 +00:00
Spring Builds
1369455b56 [artifactory-release] Release version 5.3.9.RELEASE 2021-08-17 18:02:47 +00:00
Artem Bilan
ff632504f3 Update dependencies; prepare for release 2021-08-17 11:45:34 -04:00
Artem Bilan
ef79bb782b Fix generics for customizeMonoReply()
Related to: https://stackoverflow.com/questions/68637283/how-to-customize-response-in-spring-integration-using-webflux-when-a-specific-er

The function provided for the `ConsumerEndpointSpec.customizeMonoReply()` may convert
incoming value to something else.
With wildcards it cannot be compiled without casting.

* Add `<T, V>` generic arg for the `customizeMonoReply()` to conform in and out types carrying.
* Modify `WebFluxDslTests` to demonstrate the problem and confirm the fix

**Cherry-pick to `5.4.x` & `5.3.x`**
2021-08-09 15:13:26 -04:00
Dave G
c70c98b945 GH-3610: Fix WebFluxMH for error handling
Fixes https://github.com/spring-projects/spring-integration/issues/3610

This fix changes the WebFluxRequestExecutingMessageHandler
The change specifically changes the contruction of the
WebClientResponseException to use the `create` factory method.

* Added changes and unit test to cover updated code

Updated code to use simplified exception construction that is more tolerant
  of larger payloads.
Updated unit tests to check for specific exception types.

* Corrected checkstyle errors

Corrected checkstyle error in imports.
Corrected whitespace between casts.
Corrected trailing whitespace.

* Added @author

**Cherry-pick to `5.4.x` & `5.3.x`**
# Conflicts:
#	spring-integration-webflux/src/main/java/org/springframework/integration/webflux/outbound/WebFluxRequestExecutingMessageHandler.java
#	spring-integration-webflux/src/test/java/org/springframework/integration/webflux/outbound/WebFluxRequestExecutingMessageHandlerTests.java
2021-08-09 13:40:36 -04:00
Artem Bilan
125ac454f5 Fix pattern how Lock.unlock() is used
Related to https://build.spring.io/browse/INT-MAIN-84/

The `lock.unlock()` must be called in the `finally` block of the
nested `try..catch`, not in the outer which may just fail on `lock.lockInterruptibly()`
in which case there is just not going to be anything we can `unlock()` in the end

**Cherry-pick to `5.4.x` & `5.3.x`**
2021-07-19 17:09:12 -04:00
Artem Bilan
9ebe1b3913 Make MessageHistory JSON-serializable
* Add `org.springframework.integration.history` to trusted default packaged of the `JacksonJsonUtils`
* Add `@JsonCreator` to `MessageHistory` `private` ctor to let it to be created automatically by Jackson
* Add `equals()` and `hashCode()` into `MessageHistory` for the proper `Message` comparison
* Add  `MessageHistory` into headers for testing with Redis JSON (de)serialization

**Cherry-pick to `5.4.x` & `5.3.x`**
2021-07-19 15:47:29 -04:00
Gary Russell
e714f693cf GH-3589: Reduce Delay on NIO Connection
Resolves https://github.com/spring-projects/spring-integration/issues/3589
2021-07-15 11:43:16 -04:00
Artem Bilan
1d769b8e9d Fix SourcePollingChAdFB autoStartup propagation
The `spring.integration.properties` can come with the `noAutoStartup`
property where we can specify a source polling channel adapter endpoint to
not start automatically.
Turns out the `SourcePollingChannelAdapterFactoryBean` propagates its
`autoStartup` property unconditionally which will skip the `noAutoStartup` value
because an `AbstractEndpoint.setAutoStartup()` sets an `autoStartupSetExplicitly` state

* Fix `SourcePollingChannelAdapterFactoryBean` to rely on a `Boolean` object state
and don't call target endpoint `setAutoStartup()` if it was not set
* Adjust `spring.integration.properties` in tests to use `noAutoStartup`
for some `SourcePollingChannelAdapterFactoryBean`
* Verify that property was applied in the `IntegrationFlowTests.testWithSupplierMessageSourceImpliedPoller()`

**Cherry-pick to `5.4.x` & `5.3.x`**
2021-07-07 14:20:44 -04:00
Artem Bilan
37e6457561 Remove unused imports
**Cherry-pick to `5.4.x` & `5.3.x`**
2021-07-01 15:52:51 -04:00
Artem Bilan
46f83f7afb Fix NPE for @Indexed in the MessagingGatewayReg
The `@Indexed` comes without any attributes, but it is included
into a chain via `importingClassMetadata.getMetaAnnotationTypes(ann)`.
So, skip attributes from meta annotation when it is `null`

**Cherry-pick to `5.4.x` & `5.3.x`**
2021-07-01 15:29:25 -04:00
Artem Bilan
87e11d21f8 Fix CORS registration for IntGraphController
We fail with `NoClassDefFoundError` when we use `@EnableIntegrationGraphController`
in WebFlux env without Spring MVC.
Another issue that we don't register CORS for WebFlux

* Extract top-level package protected classes for MVC and WebFlux to register CORS
in the appropriate environment according classpath
* Adjust `HttpIntegrationConfigurationInitializer` and `WebFluxIntegrationConfigurationInitializer`
for native compatibility
* Add `@Indexed` for `@MessagingGateway` for indexer support in Spring Boot and Spring Native

**Cherry-pick to `5.4.x` & `5.3.x`**

# Conflicts:
#	spring-integration-http/src/main/java/org/springframework/integration/http/config/IntegrationGraphControllerRegistrar.java

# Conflicts:
#	spring-integration-http/src/main/java/org/springframework/integration/http/config/HttpIntegrationConfigurationInitializer.java
#	spring-integration-webflux/src/main/java/org/springframework/integration/webflux/config/WebFluxIntegrationConfigurationInitializer.java
2021-07-01 14:55:37 -04:00
Spring Builds
ae263d2e1a [artifactory-release] Next development version 2021-06-09 19:20:34 +00:00
Spring Builds
50e20a9263 [artifactory-release] Release version 5.3.8.RELEASE 2021-06-09 19:20:29 +00:00
Artem Bilan
75780404d7 Upgrade dependencies; prepare for release 2021-06-09 14:35:05 -04:00
Frank Pavageau
0964a8984b GH-3570: Disable the generation of the Gradle metadata
Fixes spring-projects/spring-integration#3570

The module file with the Gradle metadata cannot be published on Maven
Central, which causes issues for some people using a repository manager such
as Artifactory. If it doesn't return a 404 HTTP status, the build fails
instead of ignoring the module.

**Cherry-pick to `5.4.x` & `5.3.x`**
2021-05-27 12:20:21 -04:00
Artem Bilan
2a3a548e46 Migrate JDBC lock tests from Derby to H2 2021-05-26 13:46:50 -04:00
Artem Bilan
4e24cbf848 Simplify the test for JDBC lock
https://build.spring.io/browse/INT-SI53X-97
2021-05-26 10:51:20 -04:00
Culebras
5938ab2fc0 GH-3567: JdbcLockRegistry: Retry TransactionSysEx
Fixes https://github.com/spring-projects/spring-integration/issues/3567

* Retry for TransactionSystemException in JdbcLockRegistry

* Unit test added for `TransactionSystemException`

* Completing author and copyright year information

**Cherry-pick to `5.4.x` & `5.3.x`**
# Conflicts:
#	spring-integration-jdbc/src/main/java/org/springframework/integration/jdbc/lock/JdbcLockRegistry.java
2021-05-26 09:57:34 -04:00
Artem Bilan
de4b8e1b5c Upgrade to SA-2.2.17; fix compatibility 2021-05-17 12:02:53 -04:00
Artem Bilan
09e5a1cf7e GH-3560 Parse mail FROM as comma-delimited header (#3562)
Fixes https://github.com/spring-projects/spring-integration/issues/3560

According RFC 5322 `FROM` and `REPLY-TO` received mail message can be
as an array of addresses.

* Fix `MailUtils` to present those arrays as comma-delimited strings for
Spring message headers
* Fix tests to deal already with several addresses for `FROM` mime header.

In the future we may change the logic to map those mime headers to arrays
as it states according the mentioned RFC

**Cherry-pick to `5.4.x` & `5.3.x`**
2021-05-05 17:01:26 -04:00
Artem Bilan
c682309edb GH-3558: Kotlin DSL: propagate generics info (#3561)
Fixes https://github.com/spring-projects/spring-integration/issues/3558

Kotlin lambdas mostly used to configure endpoints in DSL manner
are not really Java lambdas, but rather anonymous classes implementing
respective Java interfaces.

While in most cases such classes carry generic info for their method impls
properly in Java, it is somehow doesn't work well for `GenericHandler`
implemented by Kotlin lambdas

* Wrap provided `GenericHandler` in the `BaseIntegrationFlowDefinition.handle()`
into a Java lambda and call `handle()` recursively to carry an expected type to
the `LambdaMessageProcessor`
* Fix `LambdaMessageProcessor` to handle `ClassUtils.isKotlinUnit()` result of
an invocation as a `null` reply

**Cherry-pick to `5.4.x` & `5.3.x`**
2021-05-05 15:56:39 -04:00
Artem Bilan
e643477dfb GH-3554: Eval remote dir on each synchToLocal (#3556)
* GH-3554: Eval remote dir on each synchToLocal

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

The `remoteDirectoryExpression` was introduced into an
`AbstractInboundFileSynchronizer` to let end-user to evaluate a remote directory
on each poll (essentially on each `synchronizeToLocalDirectory()` call).
The fix for the https://jira.spring.io/browse/INT-4491 introduced a regression
when such an expression was evaluated only once when we call a `setRemoteDirectory()`.
So, an original purpose of this option was lost and we don't get an actual
remote dir on each poll

* Remove `evaluateRemoteDirectory()` method and its usage since it doesn't
reflect expectation of the remote dir expression property
* Reinstate the `remoteDirectoryExpression` evaluation in the
`synchronizeToLocalDirectory()`
* Propagate the result of that expression into further methods for copying
files
* Remove setting of the `remoteDirectory` variable into a global `EvaluationContext`
of the `AbstractInboundFileSynchronizer` instance since it is not thread-safe
* Instead create an `EvaluationContext` locally for each `synchronizeToLocalDirectory()`
call and set the `remoteDirectory` variable into this scoped instances
* Generate a local file name from the `localFilenameGeneratorExpression`
against locally created `EvaluationContext` with the mentioned `remoteDirectory` variable
* Cover the expected functionality with a unit-test

**Cherry-pick to `5.4.x` & `5.3.x`**

* * Fix `testRemoteDirectoryRefreshedOnEachSynchronization` according PR review
2021-04-27 16:46:28 -04:00
Artem Bilan
9981a71ec7 Fix breaking change for PersistentFileListFilter
The `AbstractPersistentAcceptOnceFileListFilter`
extends now an `AbstractDirectoryAwareFileListFilter`
and makes all the implementors to implement its `isDirectory()` method.
This is a breaking change in the point release which makes implementations
outside of the core project not compilable

The regression after: https://github.com/spring-projects/spring-integration/issues/3488
Related fix in the Spring Cloud GCP: https://github.com/spring-cloud/spring-cloud-gcp/pull/2654

* Implement an `isDirectory()` in the `AbstractPersistentAcceptOnceFileListFilter`
to let other implementations do not worry during upgrade

**Cherry-pick to `5.4.x` & `5.3.x`**
2021-04-21 11:22:49 -04:00
Spring Buildmaster
b7e7e18d84 [artifactory-release] Next development version 2021-04-14 14:54:30 +00:00
Spring Buildmaster
849c22defd [artifactory-release] Release version 5.3.7.RELEASE 2021-04-14 14:54:26 +00:00
Artem Bilan
696f490fd8 Upgrade dependencies; prepare for release 2021-04-14 10:32:53 -04:00
Alexander Pinske
c6ecd90abe Fix IMAP race condition around idle()
`IMAPFolder.idle()` by default keeps idle-ing after each response.
We don't need that, because we want to fetch the new mails immediately (over the same connection).
To make `idle()` not keep on going, we called
`folder.isOpen()` which in most cases makes `idle()` stop by calling `noop()`
internally (to keep the connection alive) which leads to the current
`idle()`-call being canceled.

The problem this commits addresses is that the call to `noop()` only
happens if there were no calls in the last second.
There is a check for that in `com.sun.mail.imap.IMAPFolder.keepConnectionAlive`.
So if a new message appears less then a second after idle started, we will miss it.

This new way interrupts `idle()` more often than before, e.g. when there
is an expunge-message (i.e. a message was deleted), which we don't care about.
But the subsequent `receive()` in IdleTask will simply get no
messages and then turn around and start idle-ing again.

**Cherry-pick to `5.3.x` & `master`**

# Conflicts:
#	spring-integration-mail/src/main/java/org/springframework/integration/mail/ImapMailReceiver.java
#	spring-integration-mail/src/test/java/org/springframework/integration/mail/ImapMailReceiverTests.java
2021-04-06 14:05:56 -04:00
Gary Russell
d6a4422aa9 GH-536: Fix test for backport 2021-03-25 18:46:35 -04:00
Gary Russell
dc51a8cbf3 GH-3526: Fix Infinite Loop in FailoverCConnFactory
Resolves https://github.com/spring-projects/spring-integration/issues/3526

`FailoverClientConnectionFactory`

The logic to detect we had iterated over all factories and including
the one from which the previous connection was established was incorrect,
causing an infite loop until one of the factory connections was successful.

Change the logic to detect we have reset the iterator and the current failure
is from the same factory as the one from which the previous connection was
established.

**cherry-pick to 5.4.x, 5.3.x**

* Add diagnostics.

* Fix race in test.

* More race fixes and diagnostics.

* Remove diagnostics.
2021-03-25 17:50:51 -04:00
Artem Bilan
a7843af045 GH-3521: Delayer: schedule release task with TX (#3525)
* GH-3521: Delayer: schedule release task with TX

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

There is a race condition when transactional `MessageStore` is used
for `DelayHandler`, so the message is not visible for reads until after TX is
committed, but a scheduled release task may be already ready after delay

* Register a `TransactionSynchronization` with scheduling a releasing task
when TX is committed

**Cherry-pick to `5.4.x` & `5.3.x`**

* Fix language in delayer.adoc

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

Co-authored-by: Gary Russell <grussell@vmware.com>
2021-03-24 11:15:11 -04:00
Trung Pham
d016dd5b6f GH-3507: Fix Tail producer for proper command
Fixes https://github.com/spring-projects/spring-integration/issues/3507

The `OSDelegatingFileTailingMessageProducer` passing command string to `Runtime.getRuntime().exec()`
may cause problems if spaces (and other special characters) are used in the filename.

* Use an array for command and its options to let the target `Runtime` to parse and
execute it properly

**Cherry-pick to 5.4.x, 5.3.x & 5.2.x**

# Conflicts:
#	spring-integration-file/src/main/java/org/springframework/integration/file/tail/OSDelegatingFileTailingMessageProducer.java
2021-03-11 14:26:45 -05:00
Artem Bilan
b7d9b87201 GH-3497: ReplyProducerCleaner: check only MPs
Fixes https://github.com/spring-projects/spring-integration/issues/3497

The `BaseIntegrationFlowDefinition.REFERENCED_REPLY_PRODUCERS` is filled up
only with the `MessageProducer` instances.
Therefore no reason to calculate a hash code for every single bean passed
to the `ReplyProducerCleaner.requiresDestruction()`

* Check for the `MessageProducer` instance before passing the bean to the
`BaseIntegrationFlowDefinition.REFERENCED_REPLY_PRODUCERS.contains()`
* Check for the `MessageProducer` in the `ReplyProducerCleaner.postProcessBeforeDestruction()`,
too.
It can be called independently of the `requiresDestruction()` and will calculate a hash code
from the bean again for nothing

**Cherry-pick to 5.4.x & 5.3.x**
2021-02-22 13:16:11 -05:00
Spring Buildmaster
a0fd6839b0 [artifactory-release] Next development version 2021-02-17 19:05:56 +00:00
Spring Buildmaster
5d09fc5304 [artifactory-release] Release version 5.3.6.RELEASE 2021-02-17 19:05:51 +00:00
Artem Bilan
e7dc2fa31e Upgrade dependencies; prepare for release 2021-02-17 13:43:22 -05:00
Artem Bilan
2ef8d8384a Fix compatibility with Java 8 compiler
**Cherry-pick to 5.3.x**
2021-02-05 17:11:29 -05:00
Artem Bilan
e894e00ff7 Fix code typo from the previous commit
**Cherry-pick to 5.3.x**
2021-02-05 17:01:55 -05:00
Gary Russell
a2d1edfbb9 GH-3488: Fix Persistent Filters with Recursion
Resolves https://github.com/spring-projects/spring-integration/issues/3488

Resolves two problems:

- When changes are made deep in the directory tree, they were not detected because
  the directory is in the metadata store and only passes the filter if a file
  immediately under it is changed, changing the directory's timestamp.

This is solved by subclassing `AbstractDirectoryAwareFileListFilter`, allowing its
`alwaysAcceptDirectories` property to be set.

- Only the filename was used as a metadata key; causing problems if a file with the
  same name appears multiple times in the tree.

This is solved with a new property on `AbstractDirectoryAwareFileListFilter` used by
the gateways to determine whether to filter the raw file names returned by the session
(previous behavior) or the full path relative to the root directory.

**cherry-pick to 5.4.x, 5.3.x**

* Some code style clean up

# Conflicts:
#	spring-integration-file/src/main/java/org/springframework/integration/file/remote/gateway/AbstractRemoteFileOutboundGateway.java
#	src/reference/asciidoc/whats-new.adoc
2021-02-05 16:53:57 -05:00
Gary Russell
8466f09f40 GH-3482: (S)FTP: Fix Recursive LS (ARFOG)
Resolves https://github.com/spring-projects/spring-integration/issues/3482

`.` and `..` should be ignored when recursing.

**cherry-pick to 5.4.x, 5.3.x**

* Fix checkstyle.

* Fix test in `file` module - test was incorrect; it would have detected this problem.
2021-02-01 16:06:20 -05:00
Artem Bilan
86c6edfce8 Ignore all the Derby tests
Not clear what is going on on CI server and how resources are not cleaned up in between builds
2021-01-27 13:11:43 -05:00
Artem Bilan
5081fa3058 Ignore Derby test 2021-01-27 12:53:21 -05:00
Artem Bilan
19e8a65061 GH-3473: Fix dead lock around lifecycleLock
Fixes https://github.com/spring-projects/spring-integration/issues/3473

When `AbstractEndpoint.start()` and `AbstractEndpoint.isRunning()`
are called from different thread on `synchronized` methods,
we may end up with a dead lock: one thread waits for monitor on
`synchronized` and another waits for the `lifecycleLock`

* Change `AbstractEndpoint.isRunning()` to a plain `return this.running;`
- there is no reason in a lock around returning this `volatile` property state

**Cherry-pick to 5.4.x & 5.3.x**
2021-01-27 11:45:43 -05:00
Spring Buildmaster
7d5d9962f1 [artifactory-release] Next development version 2021-01-13 19:27:49 +00:00
Spring Buildmaster
69406a5c2a [artifactory-release] Release version 5.3.5.RELEASE 2021-01-13 19:27:44 +00:00
Artem Bilan
99054329ae Upgrade dependencies; prepare for release
* Fix raw types error in the `MqttAdapterTests`
2021-01-13 12:46:08 -05:00
Artem Bilan
93fc5bf919 Fix another Derby test in favor of H2 2021-01-12 09:59:35 -05:00