Resolves https://github.com/spring-projects/spring-integration/issues/3418
`Class.newInstance()` can propagate checked exceptions that are not declared.
**cherry-pick/back-port to 5.3.x, 5.2.x, 4.3.x**
# Conflicts:
# spring-integration-core/src/main/java/org/springframework/integration/endpoint/AbstractPollingEndpoint.java
* GH-3370: Remove synchronized from RemoteFileUtils
Fixes https://github.com/spring-projects/spring-integration/issues/3370
The `synchronized` on the `RemoteFileUtils.makeDirectories()` makes an application too
slow, especially when we deal with different paths in different sessions
* Remove the `synchronized` from that method and rework `SftpSession.mkdir()`
to return `false` when "A file cannot be created if it already exists" exception
is thrown from the server.
Essentially make an `exists()` call to be sure that an exception is really related
to "file-already-exists" answer from the server
**Cherry-pick to 5.3.x, 5.2.x & 4.3.x**
* * Re-throw an exception in the `SftpSession.mkdir()`
when error code is not `4` or remote dir does not exist
* * Check `session.mkdir()` result in the
`RemoteFileUtils` to throw an `IOException` when `false`
* * Fix mock test to return `true` for `mkdir` instead of `null`
# Conflicts:
# spring-integration-file/src/main/java/org/springframework/integration/file/remote/RemoteFileUtils.java
# spring-integration-file/src/main/java/org/springframework/integration/file/remote/gateway/AbstractRemoteFileOutboundGateway.java
# spring-integration-file/src/test/java/org/springframework/integration/file/remote/gateway/RemoteFileOutboundGatewayTests.java
# spring-integration-sftp/src/test/java/org/springframework/integration/sftp/outbound/SftpOutboundTests.java
Close the pool so that any sessions returned after the factory is
`destroy()`ed are closed.
* Call `removeAllIdleItems()` in `close()`.
* Close sessions in `SftpStreamingMessageSourceTests`.
**cherry-pick to all supported branches**
# Conflicts:
# spring-integration-core/src/test/java/org/springframework/integration/util/SimplePoolTests.java
# Conflicts:
# spring-integration-core/src/test/java/org/springframework/integration/util/SimplePoolTests.java
# spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/connection/CachingClientConnectionFactory.java
# spring-integration-sftp/src/test/java/org/springframework/integration/sftp/inbound/SftpStreamingMessageSourceTests.java
* Remove `default close()` from `Pool` interface
* Cast to `SimplePool` in the `CSF` to call the new `close()`
Fixes https://github.com/spring-projects/spring-integration/issues/3307
The `DefaultLockRepository.acquire()` is transactional method and
can fail with the `TransactionTimedOutException`.
When we call `JdbcLock.lock()`, we expect an attempt until we really obtain a lock.
* Treat a `TransactionTimedOutException` as a `TransientDataAccessException` and
therefore retry a locking attempt logic
**Cherry-pick to 5.3.x, 5.2.x & 4.3.x**
(cherry picked from commit b0cd0156c7)
# Conflicts:
# spring-integration-jdbc/src/main/java/org/springframework/integration/jdbc/lock/JdbcLockRegistry.java
Fixes https://github.com/spring-projects/spring-integration/issues/3286
The `FileTailingEvent.getMessage()` is really meant to be as `public`
**Cherry-pick to 5.3.x, 5.2.x, 5.1.x & 4.3.x**
# Conflicts:
# spring-integration-file/src/main/java/org/springframework/integration/file/tail/FileTailingMessageProducerSupport.java
Fixes https://github.com/spring-projects/spring-integration/issues/3271
When exception happens at `.withPayload(session.readRaw(remotePath))`
in the `AbstractRemoteFileStreamingMessageSource` we don't close session.
The resource leaking happens in the caching session factory
* Add `session.close();` into the `catch (IOException e) {`
in the `AbstractRemoteFileStreamingMessageSource.doReceive()`
to clean up resources properly
**Cherry-pick to 5.2.x, 5.1.x & 4.3.x**
Fixes: https://github.com/spring-projects/spring-integration/issues/3249
When the `CachingSessionFactory` is configured with small enough pool
and it is very likely that dead lock may happen when `RemoteFileTemplate.send()`
is used.
The problem happens when we reach the `RemoteFileTemplate.exists()` call
which is done from the internal method called from already pulled from cache
`Session`
* Fix `RemoteFileTemplate` to use a `session.exists()` instead on the provided
into the method `Session`
* Demonstrate the problem in the `SftpRemoteFileTemplateTests.testNoDeadLockOnSend()`
**Cherry-pick to 5.2.x, 5.1.x & 4.3.x**
Fix RemoteFileOutboundGWTests for the proper mock
Fixes https://github.com/spring-projects/spring-integration/issues/3238
* Extract an `InputStream` from a `File` payload in the `UnmarshallingTransformer`
before parsing an XML.
Close this `InputStream` in the `finally` block to release the file resource
**Cherry-pick to 5.2.x, 5.1.x & 4.3.x**
# Conflicts:
# spring-integration-xml/src/main/java/org/springframework/integration/xml/transformer/UnmarshallingTransformer.java
# spring-integration-xml/src/test/java/org/springframework/integration/xml/transformer/jaxbmarshaling/JaxbMarshallingIntegrationTests.java
# Conflicts:
# spring-integration-xml/src/main/java/org/springframework/integration/xml/transformer/UnmarshallingTransformer.java
# spring-integration-xml/src/test/java/org/springframework/integration/xml/transformer/jaxbmarshaling/JaxbMarshallingIntegrationTests.java
Resolves https://github.com/spring-projects/spring-integration/issues/3199
When the `refreshSharedInterval` was `Long.MAX_VALUE` the test for whether
the interval was exceeded always returned true.
Use a boolean instead (already in place on master).
I will backport to 5.1.x, 4.3.x after merge.
Resolves: https://github.com/spring-projects/spring-integration/issues/3199
Previously, the FCCF did not cache a shared connection; if server 1 is down
and server 2 is up, this caused an attempt to connect to server 1 every time
we got the connection.
Add 2 options: `refreshSharedInterval` and `closeOnRefresh`, defaulting to
0 and false respectively, to maintain the same behavior as before the options
existed.
Disallow caching of the single shared connection if the delegate factories are
`CachingClientConnectionFactory` instances.
**cherry-pick to 5.2.x**
I will backport to 5.1.x, 4.3.x after review/merge.
* Polish javadocs and fix typo in docs
- bean factory and application context were not injected
- `afterPropertiesSet()` was not called
**cherry-pick to all supported branches**
# Conflicts:
# spring-integration-ip/src/main/java/org/springframework/integration/ip/config/TcpConnectionFactoryFactoryBean.java
# Conflicts:
# spring-integration-ip/src/main/java/org/springframework/integration/ip/config/TcpConnectionFactoryFactoryBean.java
Fixes https://github.com/spring-projects/spring-integration/issues/3090
Without `logout()` the FTP session is not closed at all,
but just the connection is closed.
Some FTP servers close those sessions eventually anyway, but some just
leak with resources.
**Cherry-pick to 5.1.x & 4.3.x**
Fixes https://github.com/spring-projects/spring-integration/issues/3083
`@Header("foo.bar")` means extract property `bar` from header `foo`.
Support `@Header("'foo.bar'")`, meaning get the value of header `foo.bar`.
**cherry-pick to 5.1.x, 4.3.x**
# Conflicts:
# spring-integration-core/src/test/java/org/springframework/integration/handler/MethodInvokingMessageProcessorTests.java
# Conflicts:
# spring-integration-core/src/main/java/org/springframework/integration/handler/support/MessagingMethodInvokerHelper.java
# spring-integration-core/src/test/java/org/springframework/integration/handler/MethodInvokingMessageProcessorTests.java