**Cherry-pick to 5.0.x & 4.3.x**
* Polishing after rebase
* Copyright to 2019
* Rebase and update according upstream deps
* Do not rely on `spring-web` in classpath: use `ClassUtils.forName()`
to load `ServletContextResource` class for checking
# Conflicts:
# build.gradle
# spring-integration-xml/src/main/java/org/springframework/integration/xml/selector/XmlValidatingMessageSelector.java
# spring-integration-xml/src/main/java/org/springframework/integration/xml/transformer/XsltPayloadTransformer.java
# spring-integration-xml/src/main/java/org/springframework/integration/xml/xpath/XPathUtils.java
# spring-integration-xml/src/test/java/org/springframework/integration/xml/transformer/XsltPayloadTransformerTests.java
Fixesspring-projects/spring-integration#2687
Allows any session to implement its dirty logic.
* License year was not updated
**Cherry-pick to 5.0.x**
# Conflicts:
# spring-integration-file/src/main/java/org/springframework/integration/file/remote/session/Session.java
* INT-4570: Add MessageCollectionCallback for Mongo
JIRA: https://jira.spring.io/browse/INT-4570
The `MongoDbOutboundGateway` is intended to be used with the
`requestMessage` context, however using a plain `CollectionCallback`
we don't have access to the `requestMessage`
* Deprecate `CollectionCallback` usage in favor of newly introduced
`MessageCollectionCallback` and `message-collection-callback` for XML
**Cherry-pick to 5.0.x**
* * Remove `message-collection-callback` in favor of
`MessageCollectionCallback<T> extends CollectionCallback<T>`
* * Rename a new setter to `setMessageCollectionCallback()` to avoid
reflection collision
# Conflicts:
# spring-integration-mongodb/src/main/java/org/springframework/integration/mongodb/outbound/MongoDbOutboundGateway.java
# spring-integration-mongodb/src/test/java/org/springframework/integration/mongodb/config/MongoDbOutboundGatewayParserTests.java
# spring-integration-mongodb/src/test/java/org/springframework/integration/mongodb/dsl/MongoDbTests.java
# spring-integration-mongodb/src/test/java/org/springframework/integration/mongodb/outbound/MongoDbOutboundGatewayTests.java
# spring-integration-mongodb/src/test/java/org/springframework/integration/mongodb/rules/MongoDbAvailableTests.java
# src/reference/asciidoc/mongodb.adoc
* RedisLock: Throw exception from unlock on expire
The lock might be expired in target Redis store in between `lock()` and
`unlock()`.
So, throw an `IllegalStateException` when lock is expired during
unlocking.
At the same time the lock lock is unlocked anyway.
**Cherry-pick to 5.0.x**
* * Create a new test for exception
* Add more info into the exception
* INT-4565: Fix IntComponentScan for profiles
JIRA: https://jira.spring.io/browse/INT-4565
* Propagate an `Environment` to the internal `ClassPathScanningCandidateComponentProvider`
in the `IntegrationComponentScanRegistrar` for proper profiles activation
* Ensure the logic works in the `GatewayInterfaceTests`
* Some polishing and performance improvement for the `GatewayInterfaceTests`
* Add a note about `@Profile` in the `gateway.adoc`
* Polishing for the `gateway.adoc`
**Cherry-pick to 5.0.x & 4.3.x**
* * Add not activated by profile gateway interface into the `GatewayInterfaceTests`
* More `GatewayInterfaceTests` polishing
* Fix typo in the `gateway.adoc`
* Fix Checkstyle violation
# Conflicts:
# spring-integration-core/src/test/java/org/springframework/integration/gateway/GatewayInterfaceTests.java
# src/reference/asciidoc/gateway.adoc
JIRA: https://jira.spring.io/browse/INT-4564
INT-4550 added an error log when multiple ACMHs were registered with the
same store; the error log logic was incorrect and the error was logged
when the first ACMH was registered.
(cherry picked from commit 9832f61d2a)
JIRA: https://jira.spring.io/browse/INT-4556
We definitely need to resolve a `@Bean` method to the target object to
be sure do not create a new `MessageHandler` bean.
**Cherry-pick to 5.0.x**
* INT-4550: Disallow multi aggregators on same MGS
JIRA: https://jira.spring.io/browse/INT-4550
**Cherry-pick to 5.0.x**
* * Introduce `UniqueExpiryCallback`
* Use `UniqueExpiryCallback` in the `AbstractCorrelatingMessageHandler`
* Check for uniqueness in the `AbstractMessageGroupStore`
* Remove duplicate code in the `ConfigurableMongoDbMessageStore`
* * Fix tests according a new logic
* * Address PR review
* Change `Assert.isTrue` to the `logger.error` for backward compatibility
* Revert changes in tests since we don't throw exception anymore
* Fix language on doc
* * Fix Checkstyle violation in the `AbstractMessageGroupStore`
* * Ignore `testDontReapMessageOfOtherHandler()`
https://build.spring.io/browse/INT-FATS5IC-685/
Even if we stop `SourcePollingChannelAdapter`, the task on the fly is
still going to be executed.
This way we may have extra calls to our logic.
* Use `CopyOnWriteArrayList` for the `sessionSources` to avoid
`ConcurrentModificationException` during this collection read in the
tests
**Cherry-pick to 5.0.x**
(cherry picked from commit 76c670075b)
JIRA: https://jira.spring.io/browse/INT-4545
Improve the logic in the `AbstractMethodAnnotationPostProcessor` to
check for existing `MessageHandler` and be sure that we need to register
a `ReplyProducingMessageHandlerWrapper` bean
**Cherry-pick to 5.0.x**
JIRA: https://jira.spring.io/browse/SPR-17307
The event multicaster now saves singletons in `applicationListeners`
instead of adding the bean name to `applicationListenerBeans`.
**cherry-pick to 5.0.x**
# Conflicts:
# build.gradle
* Add `RotatingServerAdvice.StandardRotationPolicy.getCurrent()` method
for better end-user experience when this class is extended
* Add NPE protection into the MQTT Channel Adapters.
Some code style polishing for them
**Cherry-pick to 5.0.x**
JIRA: https://jira.spring.io/browse/INT-4535
For the proper Spring Test Context caching support, the `ContextCustomizer`
must implement `hashCode()` and `equals()` methods
* Add `hashCode()` and `equals()` into the `MockIntegrationContextCustomizer`
* Ensure that caching works as excepted with the
`CachedSpringIntegrationTestAnnotationTests` its two sub-classes
**Cherry-pick to 5.0.x**
* INT-4543: JacksonJsonObjectMapper: fix toJsonNode
JIRA: https://jira.spring.io/browse/INT-4543
When inbound payload is type of `String`, `byte[]`, `File`, `URL`,
`InputStream` or `Reader`, we have to use an `ObjectMapper.readTree()`
function.
For all other types the `valueToTree()` should be used as a fallback
**Cherry-pick to 5.0.x**
* * Fallback to the `valueToTree()` if not valid JSON
* * Fallback to `valueToTree()` only for `String` and `byte[]`
https://www.oracle.com/technetwork/java/javase/tech/best-practices-jsp-136021.html
The set of characters in a value is also limited. If special characters may
occur, it is recommended that the value be quoted, using ObjectName.quote. If
the value for a given key is sometimes quoted, then it should always be quoted.
By default, if a value is a string (rather than a number, say), then it should
be quoted unless you are sure that it will never contain special characters.
Practically, some special characters are allowed, but we will standardize on
allowed characters in java identifiers.
In 5.0.x, this is enabled using `spring.integration.properties`.
JIRA: https://jira.spring.io/browse/INT-4541
Add test case to reproduce.
The gateway correctly sets up the `errorChannel` header so that a downstream
`MPEH` will send exceptions back to the gateway, but the `map()` function
did not check for an error message.
Check for an error message and throw the payload so that the `onErrorResume`
will route to the error channel.
# Conflicts:
# spring-integration-webflux/src/test/java/org/springframework/integration/webflux/dsl/WebFluxDslTests.java
JIRA: https://jira.spring.io/browse/INT-4538
* Add support for Jackson `TreeNode.size()` in the `AbstractMessageSplitter`
* Add overloaded `Transformers.toJson(ObjectToJsonTransformer.ResultType)`
* Modify test to verify Jackson `ArrayNode` use-case with the splitter
and aggregator
**Cherry-pick to 5.0.x**
JIRA: https://jira.spring.io/browse/INT-4539
The `IntegrationFlowBeanPostProcessor` doesn't check for prototype beans
and just override them in the application context with the singletons
* Since we can't in the DSL understand if provided object is a prototype
or not, we try to check for its bean definition by possible bean name.
Use `NamedComponent` for possible bean name to check.
* Remove `final` from the `IntegrationComponentSpec.get()` since its
result is not visible for CGI proxies when it is declared as a `@Bean`
and subsequent `getObject()` produces a new internal object
* Verify prototype beans with new test in the `IntegrationFlowTests`
**Cherry-pick to 5.0.x**
JIRA: https://jira.spring.io/browse/INT-4537Fixesspring-projects/spring-integration#2582
* Rename `ReactiveStreamsConsumer.messageHandler` property to the
`handler` for consistency with other `IntegrationConsumer` s
* Do not wrap `Subscriber` into the `MessageHandler` if that one is
already a `MessageHandler`
* Fix `MockIntegrationContext` for the logic around `ReactiveStreamsConsumer`
where it is not enough just replace a `handler`, but we also need to do
that with the `subscriber`.
Luckily the `MockMessageHandler` is also a Reactive `Subscriber`
* Clean up `MockIntegrationContext.beans` in the end of `resetBeans()`
* Improve `testing.adoc`
**Cherry-pick to 5.0.x**
If exception happens in the `callback.doWithInputStream(inputStream)`,
we don't close the `inputStream = session.readRaw(remotePath)`.
* Move the `InputStream.close()` to the `finally` block of the
`SessionCallback` action in the `RemoteFileTemplate.get()`
**Cherry-pick to 5.0.x and 4.3.x**
JIRA: https://jira.spring.io/browse/INT-4531
The `DelegatingSessionFactory` uses plain `Object` as key type
whereas the default `RotatingServerAdvice` does not.
* Change the type from `String` to `Object` in the `RotatingServerAdvice.KeyDirectory`
* Fix typos in the (s)ftp.adoc
**Cherry-pick to 5.0.x**
(cherry picked from commit 5bfd6971db)
https://build.spring.io/browse/INT-MASTERSPRING40-458/
We need to stop Inbound Channel Adapter first and only then wait for
the latch.
Otherwise there is a chance that new item is added to the collection
in between `latch.await()` and `stop()`
**Cherry-pick to 5.0.x**
(cherry picked from commit 21338d1934)