Commit Graph

9255 Commits

Author SHA1 Message Date
Gary Russell
32e221d499 SPR-17307: Fix event listener tests
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
2018-10-11 11:18:28 -04:00
Artem Bilan
490ae1b49b Some various polishing
* 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**
2018-10-10 15:27:14 -04:00
Artem Bilan
74f6c75884 INT-4535: Fix @SpringIntegrationTest for caching
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**
2018-10-10 13:01:42 -04:00
Artem Bilan
5874ae8ec4 INT-4543: JacksonJsonObjectMapper: fix toJsonNode (#2592)
* 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[]`
2018-10-10 12:24:06 -04:00
Gary Russell
993c6edc57 GH-2471: Close client on outbound adapter
Resolves https://github.com/spring-projects/spring-integration/issues/2471
2018-10-10 11:51:07 -04:00
Gary Russell
c111e1be6a JMX: Quote object name values if not identifiers
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`.
2018-10-09 16:15:47 -04:00
Gary Russell
7403e36c1e INT-4541: Fix Reactive MessagingGateway Errors
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
2018-10-08 17:50:55 -04:00
Artem Bilan
7faeee849d INT-4538: Fix Splitter for ArrayNode.size()
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**
2018-10-08 10:10:00 -04:00
Artem Bilan
3a7a14140b INT-4539: Fix Java DSL for prototype beans
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**
2018-10-06 19:35:53 -04:00
Artem Bilan
11fcda4728 INT-4537: Fix RSConsumer for MockIntegrationCtx
JIRA: https://jira.spring.io/browse/INT-4537

Fixes spring-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**
2018-10-05 14:42:29 -04:00
Artem Bilan
3644c058fa RemoteFTempl: InputStream.close() in the finally
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**
2018-10-05 12:18:35 -04:00
Michael Forstner
d9f0672df2 INT-4531: Use Object type KeyDirectory.key
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)
2018-09-14 12:50:51 -04:00
Spring Buildmaster
35bb705ae5 [artifactory-release] Next development version 2018-09-10 17:48:53 +00:00
Spring Buildmaster
777eb730b8 [artifactory-release] Release version 5.0.8.RELEASE 2018-09-10 17:48:46 +00:00
Gary Russell
04fb209489 Upgrade to SF 5.0.9.RELEASE 2018-09-10 13:12:35 -04:00
Artem Bilan
382c5dfe6c Fix RotatingServersTests race condition
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)
2018-09-08 17:45:12 -04:00
Manuel Jordan Elera
cbfadcdf61 GH-2559: Fix InboundChannelAdapter's javadoc
Resolves https://github.com/spring-projects/spring-integration/issues/2559

* Fixed minor typo that does not let generate the expected javadoc
for a attribute/method

**Cherry-pick to 5.0.x**

(cherry picked from commit cdf2ced153)
2018-09-06 14:08:45 -04:00
Gary Russell
e9e0c2cebb INT-4525 Configure TCP gateway second chance delay
JIRA: https://jira.spring.io/browse/INT-4525

Hard-coded 2 second delay is now configurable.

Also fix the logic for creating the SpEL evaluation context.

**cherry-pick to 5.0.x**

* Polishing according PR comments

(cherry picked from commit 6cc4fe530d)
2018-09-05 14:12:50 -04:00
Jonathan Oddy
b93ff3c637 Avoid leaking Zookeeper znodes in tryLock
Creating a EPHEMERAL_SEQUENTIAL node was being used to ensure the
Zookeeper connection had been established. These were never explicitly
removed, which led to tryLock effectively leaking zNodes until the
client was terminated. This in turn lead to an extremely large number of
ephemeral nodes being deleted whenever a long running service
terminated!

This fix replaces the creation of a node with a stat of "/" instead.
This has the desired effect of re-establishing the Zookeeper connection,
but is a read-only operation.

* Remove unused import

(cherry picked from commit 47a74abd30)
2018-08-31 12:59:07 -04:00
Artem Bilan
35daaae632 Fix PollableChannels for Micrometer
* Add Micrometer metrics capture for the
`PollableAmqpChannel` and `PollableJmsChannel`
* Polishing and optimization for the `AbstractPollableChannel.receive()`

**Cherry-pick to 5.0.x**
2018-08-31 11:55:04 -04:00
Gary Russell
6934690947 TCP, SSL, Configure Host Verification
Make key/trust store types configurable; add a test with host violation.

* Fix some typos and code style in the related classed and docs
* Add asserts for the store type properties

* Changes for 5.0.x to disable by default, after cherry-pick.
2018-08-29 17:04:14 -04:00
Artem Bilan
1ca1b2c165 Fix imports in DelayHandlerTests
https://build.spring.io/browse/INT-SI50X-135/

* Rename to `RouterConcurrencyTests` for consistency
2018-08-28 16:23:31 -04:00
Gary Russell
af51c9bf3e INT-4527: Delayer Retries and Error Handling
JIRA: https://jira.spring.io/browse/INT-4527
Fixes https://github.com/spring-projects/spring-integration/issues/2543

- Add error handling within the scope of a transaction
- Add `retryDelay` and `maxAttempts`
- Include the delivery attempt header in the `ErrorMessage`
- Add `transactionalRelease()` methods to the DSL

Check context in `ContextRefreshedEvent`.

Complete test case; don't schedule for re-release after a successful send after a failure.

Use `identityHashCode` for deliveries map key - error flow might change the message `hashCode`.

Debug logging

Polishing; remove parameter from the `DelayerEndpointSpec.transactionalRelease()`

* Polishing some code style

# Conflicts:
#	src/reference/asciidoc/delayer.adoc
2018-08-28 16:09:13 -04:00
Gary Russell
989a1115ce Make Headers PREFIX Constants Public
**cherry-pick to 5.0.x**

* Make `IpHeaders` prefix as `public` as well

(cherry picked from commit 5ab7d24934)
2018-08-27 16:46:05 -04:00
Nik Gorylenko
9d954cc892 fix javadoc 2018-08-26 11:02:37 -04:00
Artem Bilan
0008dbaeef JMS Test Polishing
* Add `@SuppressWarnings("serial")` for the `RequestMessageHolder`
* Use non-caching JMS CF for the Inbound endpoints in the `JmsTests`
* Make `AsyncGatewayTests extends ActiveMQMultiContextTests` to keep
embedded broker opened in between test methods
2018-08-20 18:17:23 -04:00
Gary Russell
108a7ea604 INT-4519: JmsTests Polishing 2018-08-20 15:43:26 -04:00
Artem Bilan
56ce348b2b INT-4519: Improve JMS inbound-c-a receiveTimeout (#2540)
* INT-4519: Improve JMS inbound-c-a receiveTimeout

JIRA: https://jira.spring.io/browse/INT-4519

* Modify `DynamicJmsTemplate` to default for `-1` if we get
`CachingConnectionFactory` and it is with `cacheConsumers`, otherwise
1 second
* Polishing for some JMS XML parsers, in particular remove
`receiveTimeout` population

**Cherry-pick to 5.0.x**

* * Polishing according PR comments

* * Properly use a `CachingConnectionFactory` in `JmsTests`
2018-08-20 13:46:59 -04:00
Artem Bilan
15eae700a3 Move LeaderInitiators to later phase
There is a race condition when Zookeeper `LeaderInitiator` may start
earlier than `CuratorFramework` it depends on.
This is because both of them are configured for the same default `phase` (`0`)

* Make `LeaderInitiator` and `LockRegistryLeaderInitiator` to be started
in the `Integer.MAX_VALUE - 1000` phase by default - as late as possible
* Make `CuratorFrameworkFactoryBean` to start in the `Integer.MIN_VALUE + 1000`
phase - as early as possible
* Alight lifecycle properties from the `LeaderInitiatorFactoryBean` with
defaults in the `LeaderInitiator`
* Simplify a `LeaderListenerParser` to rely on the `LeaderInitiatorFactoryBean`

**Cherry-pick to 5.0.x**
2018-08-20 11:30:09 -04:00
Artem Bilan
ed07777b4e INT-4518: Channel late-binding in Messaging Anns
JIRA: https://jira.spring.io/browse/INT-4518

* Fix `BridgeFromAnnotationPostProcessor` do not resolve `outputChannel`
for the target `BridgeHandler`
* Rework logic in the `AbstractMethodAnnotationPostProcessor` to do not
resolve a `MessageHandler` bean from the `@Bean` method when we can
just check a method return type.
* Check `BeanDefinition` instead of real bean when we consult for
conditions

**Cherry-pick to 5.0.x**
2018-08-13 18:15:33 -04:00
Gary Russell
0604258087 More JDBC, PDF doc fixes 2018-07-30 14:08:55 -04:00
Artem Bilan
af57aaebdb Fix typo in the jdbc.adoc 2018-07-30 08:47:05 -04:00
Spring Buildmaster
2a241ea945 [artifactory-release] Next development version 2018-07-27 20:26:01 +00:00
Spring Buildmaster
c986123140 [artifactory-release] Release version 5.0.7.RELEASE 2018-07-27 20:25:54 +00:00
Artem Bilan
3896acb08d Fix memory leak in MHistorConfig & MBeanExpHelper (#2531)
* Fix memory leak in MHistorConfig & MBeanExpHelper

The `MessageHistoryConfigurer` is a `BeanPostProcessor` which keeps a
store of the `TrackableComponent`.
Something similar we have with the `MBeanExporterHelper` and its local
stores populated by the `postProcessBeforeInitialization()`

* Implement `DestructionAwareBeanPostProcessor` in the
`MessageHistoryConfigurer` and `MBeanExporterHelper` to remove destroyed
beans from their caches

**Cherry-pick to 5.0.x**

* * Fix concurrency and checkstyle
* Apply Java 8 style for collections iterations
2018-07-27 15:50:55 -04:00
Artem Bilan
169eb7498d Fix imports in tests for moved classes
https://build.spring.io/browse/INT-SI50X-122
2018-07-27 13:44:42 -04:00
Artem Bilan
1014258c73 INT-4513: Clean IntManageConf from removed beans
JIRA: https://jira.spring.io/browse/INT-4513

The `IntegrationManagementConfigurer` keeps metrics beans in its local
stores.
When we add beans at runtime, they are not removed from those caches
after their removal

* Implement `DestructionAwareBeanPostProcessor` in the `IntegrationManagementConfigurer`
and clean up caches according provided bean type and its name
* Improve `ManualFlowTests` and `FtpTests` to be sure that
`IntegrationManagementConfigurer` caches are cleared after destroying
 `IntegrationFlowRegistration`

**Cherry-pick to 5.0.x**
2018-07-27 13:33:15 -04:00
Gary Russell
c50a135f23 INT-4514: Integration Graph, include dynamic flows
JIRA: https://jira.spring.io/browse/INT-4514

`getBeansOfType()` with eager init does not currently return late registered singletons.
We should not be eagerly initializing here anyway.

**cherry-pick to 5.0.x**

# Conflicts:
#	spring-integration-core/src/main/java/org/springframework/integration/support/management/graph/IntegrationGraphServer.java
2018-07-27 13:01:35 -04:00
Artem Bilan
b47c0de629 INT-4512: Add more JMS options for DSL builders
JIRA: https://jira.spring.io/browse/INT-4512

* Add `JmsListenerContainerSpec.subscriptionShared()` option

**Cherry-pick to 5.0.x**
2018-07-27 10:34:56 -04:00
Artem Bilan
7e8991a45e INT-4510: Test no memory leak in FluxMessageCh
JIRA: https://jira.spring.io/browse/INT-4510

Related to https://github.com/reactor/reactor-core/issues/1290

The `Flux.publish()` and subsequent `connect()` doesn't fuse a subscriber
for the hooks flow is interrupted (complete, or error, or disconnect).
In this case the `FluxMessageChannel.publishers` store is not cleared
from the finished publishers

* Add test-case to check the `FluxMessageChannel.publishers` store after
finishing the stream
* Add `hide()` operator with TODO to remove when an appropriate Reactor
version is ready

**Cherry-pick to 5.0.x**
2018-07-27 09:40:54 -04:00
Artem Bilan
3f66e1eb62 Upgrade to Security 5.0.7 and Data Kay SR9 2018-07-27 08:52:30 -04:00
Artem Bilan
663984a016 INT-4509: Fix memory leak for static beans stores
JIRA: https://jira.spring.io/browse/INT-4509

To avoid a re-usage of the `AbstractReplyProducingMessageHandler`,
the `IntegrationFlowDefinition` and `AbstractStandardMessageHandlerFactoryBean`
have a `static Set<>` to store already used producers and check it for
newly provided.
These stores are not cleaned when beans are destroyed leading to memory
leaks

* Implements a `DisposableBean` for the `AbstractStandardMessageHandlerFactoryBean`
to remove its `replyHandler` from the `referencedReplyProducers` on
`destroy()`
* Introduce a `IntegrationFlowDefinition.ReplyProducerCleaner` - an
`DestructionAwareBeanPostProcessor` to clean up removing `MessageProducer`
from the `IntegrationFlowDefinition.REFERENCED_REPLY_PRODUCERS`

**Cherry-pick to 5.0.x**
2018-07-26 14:19:12 -04:00
Gary Russell
d4cf440115 Upgrade Spring Framework to 5.0.8 2018-07-26 10:43:03 -04:00
Artem Bilan
2709bc142a Upgrade to the latest Kotlin
* Fix more recursive generics on factory methods
See https://jira.spring.io/browse/INT-4458

**Cherry-pick to 5.0.x**
2018-07-26 09:18:20 -04:00
Artem Bilan
5cbc622f4b Upgrade to Spring WS 3.0.2
**Cherry-pick to 5.0.x**

# Conflicts:
#	build.gradle
2018-07-25 16:43:45 -04:00
Gary Russell
4ddf423fbd Upgrade to Gradle 4.9; fix RotatingServersTests
Stop the flow before examining the stream to avoid `ConcurrentModificationException`.

**cherry-pick to 5.0.x**

# Conflicts:
#	gradle/wrapper/gradle-wrapper.jar
#	gradle/wrapper/gradle-wrapper.properties
2018-07-25 14:06:31 -04:00
Gary Russell
c216f972a8 INT-4506: Splitter: close stream and Closeables
JIRA: https://jira.spring.io/browse/INT-4506

Capture the actual splitter result in the `FunctionIterator and close it if necessary.

**cherry-pick to 5.0.x**

Add Closeable to proxy in test; remove AutoCloseable check.

Closeable extends AutoCloseable.

Fix javadocs; test for AutoCloseable instead of Closeable

Polishing - PR comments; tighten up API.

A `CloseableIterator` is now an `AutoCloseable` with an overridden
`close()`` (no exception) to avoid lint problem.

* Polishing omissions, code style and `@author`

**Cherry-pick to 5.0.x**

(cherry picked from commit bebde26)
2018-07-25 13:19:48 -04:00
Gary Russell
8101c1b8a8 INT-4505: Fix package tangle
JIRA: https://jira.spring.io/browse/INT-4505
2018-07-24 17:01:51 -04:00
Oleksii Komlyk
26bc248379 INT-4503: Fix assertion in HttpMessageHandlerSpec
JIRA: https://jira.spring.io/browse/INT-4503

Custom `ErrorHandler` can't be used if an external `RestTemplate`
is provided

* Replace `isClientSet()`` with ``!isClientSet()`` for `isTrue`
 assertion in `errorHandler` method
* Replace assertion of `restTemplate` `isNull` with assertion
`!isClientSet()` `isTrue` in the `requestFactory()` method
* Add test coverage for the `errorHandler` into the `HttpDslTests`

**Cherry-pick to 5.0.x**

(cherry picked from commit 865e216)
2018-07-24 16:15:51 -04:00
Gary Russell
0635c257fe Upgrade Micrometer to 1.0.6 2018-07-24 12:40:15 -04:00