Commit Graph

9137 Commits

Author SHA1 Message Date
Artem Bilan
e4e4ee092d Fix JdbcMessageStoreChannelTests race condition
The message in the `QueueChannel` appears for consuming a bit earlier
than TX is committed

* Introduce `afterCommitLatch` into the test verify the state
when TX is really committed and data is removed from DB

**Cherry-pick to 5.0.x and 4.3.x**
2018-04-20 09:40:25 -04:00
Artem Bilan
1f6f70b4ef Fix some sporadic tests failures
https://build.spring.io/browse/INT-MASTER-1004/
2018-04-19 17:35:50 -04:00
Artem Bilan
82cbafaaa4 Downgrade to Derby-10.13.1.1
Looks like we have started to fail much often
since upgrade to the `Derby-10.14.1.0`:
cb0d43db6b

That is also related to this https://jira.spring.io/browse/INT-4445

* Remove all the `drop` mentioning for Derby scripts -
it just doesn't support `IF EXISTS`.
More over we don't need to worry about drops since each test now starts
its own fresh embedded DB

**Cherry-pick to 5.0.x**
2018-04-19 15:00:55 -04:00
Artem Bilan
7bcf6a040a INT-4446 Improve EmbeddedJsonHeadersMessageMapper (#2422)
* INT-4446 Improve EmbeddedJsonHeadersMessageMapper

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

* Do not recreate message if not necessarily
* Do not let to generate `id` and `timestamp` if they are not mapped
* Use `smartMatch` to allow to configure negative patterns
* Introduce `PatternMatchUtils.smartMatchIgnoreCase()` for convenience

**Cherry-pick to 5.0.x**

* * Polishing `EmbeddedJsonHeadersMessageMapper`
2018-04-19 13:22:40 -04:00
Artem Bilan
15fc23c2fa INT-4447: LockRegLeaderInit: Catch unlock errors
JIRA: https://jira.spring.io/browse/INT-4447

When we get an exception during `this.lock.unlock()`, we don't revoke
leadership.
In case of external resource (e.g. JDBC) this may cause a race condition
when the second candidate is selected as leader when connection comes back

* Catch `this.lock.unlock()` exceptions and log them under DEBUG.
This way we proceed to the `handleRevoked()` logic

**Cherry-pick to 5.0.x and 4.3.x**
2018-04-18 17:07:07 -04:00
Artem Bilan
4e157725b9 INT-4448, INT-4449: Fix Gateway for no-arg method (#2420)
* INT-4448, INT-4449: Fix Gateway for no-arg method

JIRA: https://jira.spring.io/browse/INT-4448
JIRA: https://jira.spring.io/browse/INT-4449

When we are not interested in the `payload` to send, we use a gateway
method without any args, but in this case for send operation (or
send-and-receive) we should specify a default `payloadExpression`

The `MessagingGatewayRegistrar` fails with `NPE` if we don't have a
any global headers and have `defaultPayloadExpression`

Also in this case the `GatewayProxyFactoryBean` fails to send
and fallbacks to receive with the meaning "no args, not payloadExpression"

* Fix `MessagingGatewayRegistrar` to check `hasDefaultHeaders` before
processing them
* Fix `GatewayProxyFactoryBean` to consult `this.globalMethodMetadata`
if there is no `payloadExpression` for the method specific metadata

**Cherry-pick to 5.0.x and 4.3.x**

* Remove `oracle-java8-installer` since it looks like the resource
is not available anymore:

```
Location: http://download.oracle.com/otn-pub/java/jdk/8u161-b12/2f38c3b165be4555a1fa6e98c45e0808/jdk-8u161-linux-x64.tar.gz?AuthParam=1523990114_ee8c82cbe67bc87d192cb79d3b902d2f [following]
--2018-04-17 18:33:14--  http://download.oracle.com/otn-pub/java/jdk/8u161-b12/2f38c3b165be4555a1fa6e98c45e0808/jdk-8u161-linux-x64.tar.gz?AuthParam=1523990114_ee8c82cbe67bc87d192cb79d3b902d2f
Connecting to download.oracle.com (download.oracle.com)|23.53.120.105|:80... connected.
HTTP request sent, awaiting response... 404 Not Found
2018-04-17 18:35:15 ERROR 404: Not Found.
```
2018-04-18 13:48:44 -04:00
Artem Bilan
82e4679495 Increase some tests performance
https://build.spring.io/browse/INT-MASTER-999/

Since `BeanFactoryTypeConverterTests` and `CallerBlocksPolicyTests`
uses too long `Thread.sleep()` there is no guarantee that they are going
to be performed after expected 10 seconds

* Decrease `Thread.sleep()` in those tests
2018-04-10 21:08:34 -04:00
Gary Russell
6216075619 Deprecation doc polishing
Channel interceptors.
2018-04-10 19:02:07 -04:00
Artem Bilan
d807fc3692 Fix some sporadic tests failures
* Increase timeouts in the `RoundRobinDispatcherConcurrentTests` and
`ManualFlowTests`
* Fix `PollerAdviceTests` to re-use `TaskScheduler` from the ctx
instead of local, not closed instance
* Use `OnlyOnceTrigger` instead of local implementations
* Change the `primary` `Trigger` bean to the `PeriodicTrigger` as well.
The minimum interval for the `CronTrigger` is 1 seconds - it doesn't
matter for this test-case
2018-04-10 18:49:45 -04:00
Gary Russell
b940e3872b Upgrade to SF 5.1; Remove Deprecated Code
Polishing - PR Comments

Remove direct log4j usage in tests

- hazelcast depends on it; retain the dependency just in jmx

Fix hazelcast logger type
2018-04-10 18:49:42 -04:00
Artem Bilan
27318c7ee5 INT-4445: Fix JDBC tests for Derby
JIRA: https://jira.spring.io/browse/INT-4445

Looks like `/dataSource` temporary directory is busy in between different
tests.
The thought is like a high-frequently polling endpoint keeps DB resource
from removing.

* Explicitly `stop()` endpoint in the `JdbcMessageStoreChannelTests`
* Optimize
`JdbcMessageStoreChannelTests.testSendAndActivateTransactionalSend()`
to rely on the short `1` millisecond TX timeout.
This safes for us 10 seconds of the tests executions.
* Configure all the embedded DB beans for the `ignore-failures="ALL"`
as a fallback option if polling endpoint is not a cause of the concurrent
resource access.

**Cherry-pick to 5.0.x**
2018-04-09 14:41:53 -04:00
Gary Russell
af58fa4417 Upgrade to micrometer 1.0.3 2018-04-05 11:05:48 -04:00
Artem Bilan
8b3198dc36 INT-4438: No lifecycle twice in the same role
JIRA: https://jira.spring.io/browse/INT-4438

The `SmartLifecycleRoleController` is based on the `MultiValueMap`
which used internally a `List` for the values.
With such an architecture we can add the same value several times.
On the other hand we are iterating over `Lifecycle`s in the role and
build a `Map` for their running status.
In this case when `NamesComponent`s return the same name the Java
`Collectors.toMap()` fails with a duplicate key error.

In any cases it would be better do not allow to add the same lifecylce
several time to the role or different with the same name.

* Add search logic to the `addLifecycleToRole()` to fail fast with the
`IllegalArgumentException` because a lifecycle with the same name is
already present in the role

**Cherry-pick to 5.0.x**

* Remove redundant `this.initialized = false` from the
`AbstractPollingEndpoint.doStop()`

Add `allEndpointsRunning()` verification to the `EndpointRoleParserTests`

Polishing
2018-04-02 17:17:47 -04:00
Artem Bilan
a65d05cdbf Increase timeout for PollingConsumerEndpointTests
https://build.spring.io/browse/INT-SI50X-20

Looks like 5 seconds is not enough to wait for the test completion,
especially on CI server

* Refactor `PollingConsumerEndpointTests` to use `OnlyOnceTrigger`
from the test-support module instead of local `Trigger` implementation
* Increase timeout for latch in the `OnlyOnceTrigger` to 10 seconds

**Cherry-pick to 5.0.x**
2018-04-02 14:44:56 -04:00
Artem Bilan
5cdcd81444 Fix NPE in the TcpNetServerConnectionFactory
https://build.spring.io/browse/INTSAMPLES-NIGHTLY-2413

When we fail with the
`java.net.BindException: Address already in use (Bind failed)` in the
`TcpNetServerConnectionFactory.run()`, the `serverSocket` property
remains `null` and we get `NPE` in the `catch` block trying to `close()`
the socket.

* Call `stop()` instead which has all the required protections.

**Cherry-pick to 5.0.x and 4.3.x**
2018-04-02 13:36:02 -04:00
Gary Russell
544de6bf5f Add BoundRabbitChannelAdvice
Polishing and docs

Polishing - DEBUG log for confirms; add integration test

Polishing - PR Comments

Renamed Advice

Verify acks logged.

Polishing - more PR comments

Renamed to BoundRabbitChannelAdvice.

* Extract `ConfirmCallback`s instances for optimization
* Remove unused constant
2018-03-29 15:53:57 -04:00
Artem Bilan
8afdcb4893 Fix Transformers usage in Docs
**Cherry-pick to 5.0.x**
2018-03-27 12:23:05 -04:00
Gary Russell
1cd6c11808 INT-4443: Use SimpleEC for uriVariablesExpression
JIRA: https://jira.spring.io/browse/INT-4443

**cherry-pick to 5.0.x, 4.3.x**

Polishing; use data binding accessor in test evaluation contexts.

Add `.withInstanceMethods()`

See https://jira.spring.io/browse/SPR-16588?focusedCommentId=158041&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-158041

* Polishing according PR comments
2018-03-26 16:48:37 -04:00
Artem Bilan
7b86ca7bc8 Upgrade to H2 1.4.197
https://build.spring.io/browse/INT-FATS5IC-457

The H2 `1.4.197` has fixed some issues
(in particular https://github.com/h2database/h2database/issues/178)
and introduced some breaking changes for us, although they are
reasonably good.

* Fix `JdbcOutboundGatewayParserTests` to use correct identifiers
for returned generated keys instead of previously used `SCOPE_IDENTITY()`

**Cherry-pick to 5.0.x and 4.3.x**
2018-03-26 12:24:48 -04:00
Artem Bilan
da6f47cf40 Reorder beans in JdbcPollingChAParserTests cofigs
https://build.spring.io/browse/INT-AT42SIO-820/

The test configs use `fixed-rate="100"`.
This way when Inbound Channel Adapter is declared earlier in the
config than `<jdbc:embedded-database>`, there is a chance that we start
to poll DB before it is really initialized.

* Reorder config so embedded DB is initialized before an
Inbound Channel Adapter

**Cherry-pick to 5.0.x, 4.3.x and 4.2.x**
2018-03-26 11:07:36 -04:00
Nathan Kurtyka
ae2aa8b6d1 INT-4440: Support serialized UUID in headers
JIRA: https://jira.spring.io/browse/INT-4440

The previous fix eliminated an extra `generateId()` call, but at the
same introduced regression do not populate `id` and `timestamp` from
the serialized state, e.g. after JSON transferring over the network

* Introduce a couple utility methods in the `MutableMessageHeaders`
to extract and parse `id` and `timestamp` from the provided headers

**Cherry-pick to 5.0.x**
2018-03-23 09:59:57 -04:00
Gary Russell
a9eb922d35 Fix AMQP MessageSource Tests
https://build.spring.io/browse/INT-MASTER-983/

Race between the poller and template to get the requeued message.

Also add trace logging to the acknowledgment.

**cherry-pick to 5.0.x**
2018-03-22 18:15:38 -04:00
Gary Russell
2975255be8 INT-4439: Micrometer Docs Polishing
JIRA: https://jira.spring.io/browse/INT-4439
2018-03-22 15:27:13 -04:00
Gary Russell
f9d51989a8 INT-4441: Fix ACMH Concurrency Problem
JIRA: https://jira.spring.io/browse/INT-4441

Possible concurrent updates to `AbstractCorrelatingMessageHandler.groupIds` and
`expireGroupScheduledFutures`.
2018-03-22 15:25:38 -04:00
Artem Bilan
74504326c9 INT-4434: Allow to use sub-flows from beans
JIRA: https://jira.spring.io/browse/INT-4434

There were a restriction introduced since Java DSL `1.2` do not use
`IntegrationFlow` beans for sub-flow definitions, e.g. in routers.
It is considered as regression by community because it worked before
in version `1.1`

* Introduce `IntegrationFlow.getInputChannel()` to be able to bridge
from the main flow to the flow which is treated as sub-flow.
In most cases we talk about an independent bean for the `IntegrationFlow`
which can be used as a stand along one and as a sub-flow in other flow

**Cherry-pick to 5.0.x**

Add JavaDocs to the `EndpointSpec.obtainInputChannelFromFlow()`
2018-03-22 14:34:56 -04:00
Artem Bilan
b1a3ca764c INT-4433: Optimize @Publisher metadata
JIRA: https://jira.spring.io/browse/INT-4433

The current `MessagePublishingInterceptor` behavior is to parse expressions
on each method invocation what is not so efficient at runtime

* Introduce `default` `Expression`-based method to the `PublisherMetadataSource`
contract and call existing String-based methods for backward compatibility.
* Deprecate String-based `PublisherMetadataSource` methods in favor of newly
introduced `Expression`-based
* Implement new `getExpressionForPayload()` and `getExpressionsForHeaders()`
in all the `PublisherMetadataSource` implementations
* Cache parsed `Expression` s during initialization in the `PublisherMetadataSource`
implementations or do that on demand in the `MethodAnnotationPublisherMetadataSource`
by provided method basis
* Introduce `MethodAnnotationPublisherMetadataSource#metadataCacheLimit` and populate
its value from the `@EnablePublisher` or `<int:annotation-configuration>`
* Implement `entrySet()` and `values()` in the `ExpressionEvalMap`

**Cherry-pick to 5.0.x**

* Add `@SuppressWarnings("varargs")` to avoid compilation warning

* Remove LRU cache logic - it's fine to cache all the info about methods
in the classpath
2018-03-21 16:35:01 -04:00
Artem Bilan
12301f7fae LockRegistryLeaderInitiator: Add DEBUG for errors
For better traceability for errors during lock acquiring add DEBUG
logging message in the `catch` block before returning back to the main
loop for the next acquiring attempt

**Cherry-pick to 5.0.x and 4.3.x**
2018-03-21 12:10:55 -04:00
Artem Bilan
4f616e926e Fix unused imports
https://build.spring.io/browse/INT-MASTER-978/

**Cherry-pick to 5.0.x**
2018-03-21 11:49:21 -04:00
Yicheng Feng
ed00f62549 INT-4432: Mock Handler: fix output channel
JIRA: https://jira.spring.io/browse/INT-4432

The `MockIntegrationContext.substituteMessageHandlerFor()` method
cannot get the correct output channel of target message handler
since the `outputChannel` property is not initialized.

* Use `getOutputChannel()` method instead of directly accessing
the `outputChannel` property. The `getOutputChannel()` method
guarantees the correct value is retrieved.

* Polishing Copyrights and author name
* Simplify `MockMessageHandlerTests.testHandlerSubstitutionWithOutputChannel()`
and its configuration

**Cherry-pick to 5.0.x**
2018-03-21 11:29:49 -04:00
Artem Bilan
bcf4402b91 INT-4437: Scatter-Gather: reinstate replyChannel
JIRA: https://jira.spring.io/browse/INT-4437

The `ScatterGatherHandler` overrides a `replyChannel` header for the
scatter message to its internal queue and doesn't reinstate the original
`replyChannel` header when producer a gather result message

* Rebuild gather result message with population a proper `replyChannel`
header from the request message and removing a `gatherResultChannel`
header

**Cherry-pick to 5.0.3 and 4.3.x**

Polishing
2018-03-20 16:48:33 -04:00
Gary Russell
f44eb37d3c Revert "Revert AMQP Upgrade until Cairo released"
This reverts commit 8853e06cc2.
2018-03-19 13:16:27 -04:00
Gary Russell
8853e06cc2 Revert AMQP Upgrade until Cairo is released
https://build.spring.io/browse/INT-FATS5IC-449/
2018-03-18 11:10:02 -04:00
Artem Bilan
027021d6e4 Move XSDs to version 5.1
* Upgrade to Spring AMQP-2.1 and fix compatibility
2018-03-17 09:58:40 -04:00
Gary Russell
82f252dd00 INT-4390: Fix tangles
JIRA: https://jira.spring.io/browse/INT-4390

Phase I: flow context/registration cycle

- extract interfaces
- rename implementations to `Standard...`

Phase II - dsl<->dsl.channel tangles

Move the channel specs to dsl.

Fix missing refactorings

(Not related to DSL) - rename core `event` package to `events`

- avoid collision with event module package
- fix tangle caused by `MessageGroupExpiredEvent`.

Phase III - dsl<->config.dsl

- move classes from config.dsl to dsl

(Not related to DSL) - fix many tangles caused by graph being a sub-package of support.management
 - make `graph` a top-level package

(Not related to DSL) - move `IntegrationManagementConfigurer` from
`management` to `config` - tangle between core and management
* Polishing Copyrights, diamonds, some JavaDocs and What's New
2018-03-16 14:59:47 -04:00
Ruslan Stelmachenko
7f25cba262 INT-4430: FileSplitter close reader on exception
JIRA: https://jira.spring.io/browse/INT-4430

When Iterator-based `FileSplitter` splits the file, and an exception 
throws in downstream flow (in the same thread), the exception propagates 
to the caller leaving underlying file reader opened.

This commit changes `AbstractMessageSplitter` the way, that, 
when any exception happens, if Iterator implements `java.io.Closeable`, 
its `close()` method will be called before propagating exception.

Also `FileSplitter`'s underlying iterator implements `Closeable` now.

* Make `CloseableIterator` to follow `Closeable` contract.

Now `CloseableIterator.close()` declares `IOException` and can be used 
as base interface for `FunctionIterator`.

* Adjust tests.

Adjust tests to reflect the fact that we call `close()` on the reader 
one more time in the end of iterator.

**Cherry-pick to 5.0.x and 4.3.x**
2018-03-16 10:26:41 -04:00
Jon Schneider
f77fd78fb3 Upgrade to Micrometer 1.0.2
Release notes: https://github.com/micrometer-metrics/micrometer/releases/tag/v1.0.2
2018-03-15 10:35:06 -04:00
Artem Bilan
40aa5672d7 INT-4428: MethodParam usage: fix race condition
JIRA: https://jira.spring.io/browse/INT-4428

Using `increaseNestingLevel()` and `decreaseNestingLevel()` is not
thread-safe and may cause a race conditions

* Use `MethodParameter.nested()` instead which creates and cache a new
`MethodParameter` for the nested generic type

**Cherry-pick to 5.0.x**
2018-03-14 09:22:00 -04:00
Gary Russell
7f20dd1b2a INT-4392: Polishing
JIRA: https://jira.spring.io/browse/INT-4392

Avoid the need for reflection on the `MicrometerMetricsCaptor`.
 - move facade interfaces to a sub-package.
Remove deprecated `MicrometerMetricsFactory.
2018-03-13 19:19:47 -04:00
Artem Bilan
a4eb4ec9b1 GH-2388: Fix HeaderEnricherSpec for adviceChain
Fixes spring-projects/spring-integration#2388

During `HeaderEnricherSpec` refactoring the `adviceChain` population
has been missed, alongside with many other `AbstractReplyProducingMessageHandler`
options from the `ConsumerEndpointSpec`

* Refactor `HeaderEnricherSpec` to build `HeaderEnricher` and an
appropriate `MessageTransformingHandler` from the ctor to be able
to pick up an `adviceChain` automatically in the `ConsumerEndpointSpec.get()`

**Cherry-pick to 5.0.x**
2018-03-13 12:25:06 -04:00
Gary Russell
4552a80095 INT-4392: Fix tangles
JIRA: https://jira.spring.io/browse/INT-4392
JIRA: https://jira.spring.io/browse/INT-4391
JIRA: https://jira.spring.io/browse/INT-4393

Resolve class and leaf package tangles in:

- core (except DSL)
- file
- http

- move `StaticMessageHeaderAccessor` to root `integration` package
- move acknowledgment related classes to a new `acks` package
- move `MMIH` to `handler.support`, alongside argument resolvers, also `HandlerMethodArgumentResolversHolder`
- move `ErrorMessagePublisher` to `core`
- move `PatternMatchUtils` to `support.utils`
- move `MessageSourceManagement` to `support.management`
- remove direct reference to `MicrometerMetricsCapter` from `IntegrationManagementSupport`
- add new class `MetricsCaptorLoader`

- move `OperationsCallback` to inner interface in `RemoteFileOperations`

- move `HttpContextUtils` to `config`

* Simplify MetricsCaptor loading.

* Polishing
2018-03-13 11:22:56 -04:00
Gary Russell
525eb004ec Update Master to 5.1.0.BUILD-SNAPSHOT
`JedisConnection.execute()` no longer accepts `null` arguments.

8adea79e67

* Spring Security 5.1; Reactor 3.2
2018-03-12 21:13:32 -04:00
Gary Russell
6718d8d433 INT-4423: Make Micrometer dependency optional
JIRA: https://jira.spring.io/browse/INT-4423

Add a facade on top of micrometer so the dependency can
be optional.t

Next iteration - PR comments

Checkstyle

More polishing; static classes etc.

checkstyle

Further polishing; docs; auto-register `MicrometerMetricsCaptor`.

Polishing - move captor load to a static method on the captor.

* Fix Checkstyle violation
* Some code style polishing
2018-03-09 15:24:29 -05:00
jmaxwell
a92933e800 INT-4427 add value attribute to the @Publisher
JIRA: https://jira.spring.io/browse/INT-4427
2018-03-07 20:12:46 -05:00
Gary Russell
f479270dcd Support JUnit5 in tests
* wrapper
2018-03-05 16:50:33 -05:00
Gary Russell
212f478151 INT-4417: Add @EndpointId
JIRA: https://jira.spring.io/browse/INT-4417

Provide more flexibility with bean naming when using EIP Annotations with
Java configuration.

* Polishing - PR Comments

* More polishing - remove `@Inherited`; disallow with more than one EIP annotation.
2018-03-05 14:34:04 -05:00
Gary Russell
bc25eff34c Polishing 2018-03-05 11:21:40 -05:00
Gary Russell
6065745913 INT-4421: Fix failedMessage in some exceptions
JIRA: https://jira.spring.io/browse/INT-4421

If a component invoked by an SPCA threw a `MessagingException` with no
`failedMessage`, the resulting ErrorMessage payload had no `failedMessage`.

The `UnicastingDispatcher` had a check for this so it wasn't an issue
as long as at least one `DirectChannel` was between the poller and the
component.

Promote the wrapping code to `IntgrationUtils` and invoke it from
places that blindly rethrew `MessagingException`s.
2018-03-05 11:21:40 -05:00
Gary Russell
1c4db65b1c Channel Incorrectly started a second timer
* Some code style polishing for affected classes
2018-03-02 14:08:53 -05:00
Spring Buildmaster
f8774b9a32 [artifactory-release] Next development version 2018-02-28 19:38:38 +00:00
Spring Buildmaster
acaebcb107 [artifactory-release] Release version 5.0.3.RELEASE 2018-02-28 19:38:31 +00:00