Commit Graph

8537 Commits

Author SHA1 Message Date
Gary Russell
4c68e22d87 INT-3923: Fix MQTT Reconnect Logic
JIRA: https://jira.spring.io/browse/INT-3923

Fixes: #2046

Previously, when connection is lost, the inbound adapter attempted to reconnect on
a schedule with a fixed delay.

If a connection was again lost, while the schedule is still running, we can end up
with another scheduled task running.

This is benign aside from the DEBUG log noise because the scheduled task tests the
connection before reconnecting.

However, if the `recoveryInterval` is short, it could consume CPU.

Change the reconnect to be a one-time scheduled task and reschedule if it fails to
reconnect.

Synchronize all access to the `connected` field.

Add a test case with a short recovery interval, before this fix, we see many logs
`Attempting reconnect`.

Conflicts:
	spring-integration-mqtt/src/main/java/org/springframework/integration/mqtt/inbound/MqttPahoMessageDrivenChannelAdapter.java
	spring-integration-mqtt/src/test/java/org/springframework/integration/mqtt/MqttAdapterTests.java

* Fix single-arg `Assert` method usage in the `AbstractCorrelatingMessageHandler`
2017-02-02 13:54:26 -05:00
Artem Bilan
6e7653f18f INT-4221: Properly use Spring's Assert class
JIRA: https://jira.spring.io/browse/INT-4221

* Upgrade to those versions of Spring project dependencies which potentially will provide similar fix

**Cherry-pick to 4.3.x**
2017-01-30 22:47:16 -05:00
Gary Russell
d9c6ffee74 INT-4217: SpEL Compilable for Required Header Args
JIRA: https://jira.spring.io/browse/INT-4217

Previously, SpEL method calls with required header parameters had the following form:

    #target.messageAndHeader(message, headers['number'] != null ? headers['number'] : T(org.springframework.util.Assert).isTrue(false, 'required header not available: number'))

The SpEL compiler cannot compile this because the else clause of the ternary has no `exitDescriptor` to indicate the type.

Change the expression to use a function for required headers.
Also use an Elvis operator when possible.

Some examples of new expressions:

    #target.optionalAndRequiredHeader(headers['prop'] ?: null, #requiredHeader(headers, 'num'))

    #target.optionalAndRequiredDottedHeader(headers['dot1'] != null ? headers['dot1'].foo : null,
         #requiredHeader(headers, 'dot2').baz

In the second case, we can't use an Elvis because we're accessing a `foo` property of the header.

__cherry-pick to 4.3.x__

- make `ParametersWrapper` `static`
- minor conflicts in imports
- remove the perf test

* Polishing: remove redundant annotation args for their default values usage
* Revert `java.util.Optional` import in favor of literal for Java < 8
* Make `AnnotatedTestService` as `public` to get compilable SpELs
* Remove performance test from the `MethodInvokingMessageProcessorTests`
2017-01-27 15:30:45 -05:00
Aaron Grant
2f00285c3b INT-4216: Fix ClassCast in ChainFileListFilter
JIRA: https://jira.spring.io/browse/INT-4216

Add test for running empty array through `ChainFileListFilter`

Assure no exceptions are throw when filter input is empty.

INT-4216: Add fix for ChainFileListFilter edge case

INT-4216: Fix checkstyle error on test class

Add copyright header to test file

* Polishing for `ChainFileListFilter` JavaDocs
* Move `CompositeFileListFilterTests` and `ChainFileListFilterIntegrationTests` to the `filters` package instead of `file` core

(cherry picked from commit 1f9d07a)
2017-01-26 15:07:53 -05:00
Spring Buildmaster
4f4b2681b6 [artifactory-release] Next development version 2017-01-25 21:04:14 +00:00
Spring Buildmaster
5417468eb8 [artifactory-release] Release version 4.3.7.RELEASE 2017-01-25 21:04:08 +00:00
Artem Bilan
35a633d304 INT-4215: Add ChainFileListFilter
JIRA: https://jira.spring.io/browse/INT-4215
Fixes GH-1998 (https://github.com/spring-projects/spring-integration/issues/1998)

Just make an `CompositeFileListFilter` extension which chains result of the previous filter to the next

**Cherry-pick 4.3.x**
2017-01-25 15:24:59 -05:00
Artem Bilan
9dfc7f4671 Fix Mockito import 2017-01-23 10:05:46 -05:00
Gary Russell
0c95a399e5 INT-4212: FileWritingMessageHandler.flushWhenIdle
JIRA: https://jira.spring.io/browse/INT-4212

Add an option to flush after the `flushInterval`, regardless of intermediate writes.

Rename `lastFlush` to `firstWrite`

Polishing

**Cherry-pick to 4.3.x**
2017-01-23 09:51:53 -05:00
Gary Russell
f23c679f67 Update to Spring AMQP 1.6.7
Also added a note to the 5.0 migration guide about the change of
`AMQPHeaders.CORRELATION_ID` from `byte[]` to `String`.
2017-01-21 11:15:51 -05:00
Gary Russell
e6e2e01951 Polishing for Previous Commmit
Container needs a queue.
2017-01-21 10:45:17 -05:00
Gary Russell
d6f8120393 AMQP IO Platform Brussels Compatibility
https://build.spring.io/browse/INT-MJATS41-884/

The gateway must start the template.
2017-01-21 09:53:39 -05:00
Gary Russell
8a1aa98f72 Doc Copyright 2017 2017-01-20 10:02:14 -05:00
Artem Bilan
626466bac8 Compatibility with previous SF versions
https://build.spring.io/browse/INT-MJATS41-872
2017-01-09 10:34:57 -05:00
Artem Bilan
a39c8bef41 Fix compatibility with the latest SF
https://build.spring.io/browse/INT-MJATS41-869

* Revert to `B-S` versions for SA
* Since `MessagingException.toString()` now includes and `failedMessage` as well, a comparision with `TcpConnectionExceptionEvent.toString()` should be a bit different

See https://jira.spring.io/browse/SPR-15091
2017-01-06 10:38:01 -05:00
Artem Bilan
0c2ba3f761 INT-4202: Fix StoredProcOutboundGateway NPE
JIRA: https://jira.spring.io/browse/INT-4202

The `StoredProcOutboundGateway` uses `MessageBuilder` directly for procedure result without any conditions.
If procedure result is `null`, `MessageBuilder.withPayload` throws `java.lang.IllegalArgumentException: payload must not be null`.

* Since the super `AbstractReplyProducingMessageHandler` class takes care about `null` reply properly via its `requiresReply` property and really uses `MessageBuilder`
 for reply, just fix `StoredProcOutboundGateway` to return procedure result as is from the `handleRequestMessage()` implementation
* Fix some typos and code style
* Increase some JDBC tests performance changing `Thread.sleep()` solution to proper `PollableChannel.receive()` or iterations over expected result

**Cherry-pick to 4.3.x**

Update `@Copyright` to 2017

Make `StoredProcOutboundGateway` as `requiresReply = true` by default

Revert `setRequiresReply(true)` change

Specify `setRequiresReply(true)` only if `expectSingleResult == true` and `setRequiresReply()` hasn't been called explicitly

Conflicts:
	spring-integration-jdbc/src/main/java/org/springframework/integration/jdbc/StoredProcOutboundGateway.java
	spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/JdbcMessageStoreChannelIntegrationTests.java
	spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/config/StoredProcOutboundGatewayParserTests.java
Resolved.
2017-01-04 18:24:10 -05:00
Gary Russell
85a825cd75 INT-4203: Fix Docs
Change setter name.
2017-01-04 17:37:36 -05:00
Gary Russell
3301da4157 INT-4203: Expression RH Advice Improvements
JIRA: https://jira.spring.io/browse/INT-4203

Add channel names for easier use in DSL.

Add documentation (boot) example.

Normalize Expression Setters; add Javadocs

Polishing - SPR-15091

Tiny code style polishing

Conflicts:
	spring-integration-core/src/test/java/org/springframework/integration/dsl/flows/IntegrationFlowTests.java
	src/reference/asciidoc/handler-advice.adoc
    spring-integration-core/src/test/java/org/springframework/integration/handler/advice/ExpressionEvaluatingRequestHandlerAdviceTests.java

* Restore removed methods in the `ExpressionEvaluatingRequestHandlerAdvice` and deprecate them
* Remove methods in the `ExpressionEvaluatingRequestHandlerAdvice` introduced since `5.0`
2017-01-04 16:21:48 -05:00
Artem Bilan
dd72b9b63d INT-4197: Fix Annotation Case when not messages
JIRA: https://jira.spring.io/browse/INT-4197

Since `Collection<Message<?>>` can be possible only if we are dealing with messages as a group (`MethodInvokingMessageListProcessor`), the case with the `List<?>` param for Messaging Annotation method should not be treated as candidate for `messages` collection.

* Add `this.canProcessMessageList` condition to avoid `messages` SpEL expression when we are not in the `MethodInvokingMessageListProcessor` environment

**Cherry-pick to 4.3.x**

* Fix Array creating formatting
* Add comment about `ReflectiveMethodExecutor` to the `testRouterWithListParam()`
* Send one test data as as `Collection` to be sure that `@Router` parameters mapping works well
2017-01-03 15:05:41 -05:00
Gary Russell
3ce1fcb110 INT-4199: Fix Asserts with no Message
JIRA: https://jira.spring.io/browse/INT-4199

MQTT and JDBC.

Conflicts:
	spring-integration-jdbc/src/main/java/org/springframework/integration/jdbc/store/JdbcChannelMessageStore.java
Resolved.
2017-01-03 13:23:15 -05:00
Gary Russell
8fd9290509 INT-4201: Fix Gateway Param Annotation Aliases
JIRA: https://jira.spring.io/browse/INT-4201

name<->value alias was not processed correctly so using
`@Header(name = "baz") String baz` did not work.

Use `SynthesizingMethodParameter`.

(cherry picked from commit 0cbfd6e)
2017-01-03 11:44:03 -05:00
Gary Russell
6cd0845cfa INT-4198: TCP: Add Hook to Customize SSLEngine
JIRA: https://jira.spring.io/browse/INT-4198

Enable setting properties like `needClientAuth` on the `SSLEngine` - when not using
NIO, this can be set on the server socket with a socket support implementation.

Add `nio-connection-support` to namespace.

Improved "Advanced Techniques" documentation, using this use case as an example.

Fail fast with NIO when SSL handshaking fails.

Polishing - PR Comments

More Polishing

* Final polishing
- fix several typos in log messages
- clean up `TcpConnectionFactoryFactoryBean` JavaDocs from redundant imports
- remove redundant `InitializationBean` functionality from the `DefaultTcpNetSSLSocketFactorySupport` as well

Conflicts:
	spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/SocketSupportTests.java

* Resolve Java 8 code style and revert `afterPropertiesSet()` with `@Deprecated`
2016-12-29 18:15:18 -05:00
Artem Bilan
8d703992ea MongoDbInboundChAdapterIntTests race condition
Since we can have a result message in the `replyChannel` before the TX commit, a subsequent adapter `stop()` causes the current task interruption,
 therefore TX rallback.
That's why we see `semaphore.acquire()` interruption and don't see message in the  `afterCommitChannel`

**Cherry-pick to 4.3.x**

(cherry picked from commit bdab0aa)
2016-12-29 11:59:11 -05:00
Artem Bilan
f0a48dd89e LockRegistryLeaderInitiatorTests race condition
There is tiny time window when `LockRegistryLeaderInitiator` can be stopped during `Context.yield()` invocation.
In this case the `LockRegistryLeaderInitiator` goes to the stopped state, but a new `leaderSelector` is submitted for election.

Therefore in the `LockRegistryLeaderInitiatorTests.competing()` the second initiator may not get be granted because there is uncontrolled `leaderSelector` task on background.

We can overcome it with always `this.initiator.stop()` for the `LockRegistryLeaderInitiatorTests`, but to be sure in the fix it would be better to leave as is.

Also add `@Rule Log4jLevelAdjuster` for future diagnostics

**Cherry-pick to 4.3.x**

(cherry picked from commit 56929cd)
2016-12-27 14:09:53 -05:00
Artem Bilan
ca079dd0d1 IdempotentReceiverAutoProxyCreatorInit refinement
No reason to load class one more time if `MethodMetadata` is already `StandardMethodMetadata`

See https://jira.spring.io/browse/SPR-14505

**Cherry-pick to 4.3.x**

(cherry picked from commit 1e46fb8)
2016-12-24 16:04:41 -05:00
Artem Bilan
5f7512086e Compatibility with the latest SF
https://build.spring.io/browse/INT-MJATS41-856

According the attempts to read method from class in the proper order, there is a fix in SF to do that via ASM.
Therefore `beanDefinition.getSource()` isn't `StandardMethodMetadata` any more.

Fortunately we can simply assert against `returnTypeName` to check for the `MessageHandler`

See https://jira.spring.io/browse/SPR-14505

**Cherry-pick to 4.3.x**

(cherry picked from commit f3460bd)
2016-12-24 11:53:00 -05:00
Artem Bilan
efee77be02 Fix Java 6 compatibility
https://build.spring.io/browse/INT-SI43X-76
2016-12-23 09:46:07 -05:00
Gary Russell
44b16cbe81 INT-4195: More Aggregator Performance Improvements
JIRA: https://jira.spring.io/browse/INT-4195

Avoid the N^2 search in `SequenceAwareMessageGroup` when the group is a
`SimpleMessageGroup`.
Avoid the use of the header accessor if the N^2 search is needed (SPR-15045).

Polishing - PR Comments

(cherry picked from commit a466579)
2016-12-23 09:38:43 -05:00
Gary Russell
ed1c631779 INT-4193: Large Group Aggregation Performance
JIRA: https://jira.spring.io/browse/INT-4193

When using the internal `SequenceAwareMessageGroup` within an correlating
message handler, the messages were copied to a new collection before
checking for duplicate sequences in `canAdd()`.

This was unnecessary since we never add anything to this group, if `canAdd()`
returns true, the message is added to the store; this group is discarded.

Instead, use the message collection from the original group; although it is
not modifiable, this is not an issue because we don't need to modify it.
2016-12-22 14:20:45 -05:00
Artem Bilan
ea2b5df573 TcpNioConnectionReadTests: One more error message
https://build.spring.io/browse/INT-MJATS41

**Cherry-pick to 4.3.x**

(cherry picked from commit 168d91c)
2016-12-22 11:07:29 -05:00
Artem Bilan
bff4dc36c2 Fix MongoDbICAdapterIntTests race condition
Partial back port from c0a507c36c
2016-12-22 11:01:36 -05:00
Spring Buildmaster
9bd782f209 [artifactory-release] Next development version 2016-12-21 16:18:53 +00:00
Spring Buildmaster
d43e485aaa [artifactory-release] Release version 4.3.6.RELEASE 2016-12-21 16:18:48 +00:00
Artem Bilan
fedb65c6fb Compatibility with the latest Spring AMQP-1.6.6
This must be back-ported to `4.3.x` after upgrade to the particular `1.6.x` or `1.7.x`
2016-12-21 10:49:41 -05:00
Gary Russell
c5ef70eb92 Update to SF 4.3.5, Spring AMQP 1.6.6 2016-12-21 10:35:10 -05:00
Artem Bilan
4026753b40 INT-4181: Refactor IMBE to use IntMngmtConfigurer
JIRA: https://jira.spring.io/browse/INT-4181

* To avoid duplicate code move actual `Metrics` resolution to the `IntegrationManagementConfigurer` and delegate from the `IntegrationMBeanExporter` for backward compatibility
* Minor refactoring and improvements in the `IntegrationMBeanExporter`
* Fix typos in the `jms/AsyncGatewayTests`

**Cherry-pick to 4.3.x**
2016-12-20 12:44:28 -05:00
Gary Russell
7eeb4e3535 Fix SF 4.3.5 Test Compatibility
Default Conversion Service.

a7ba63d425 (diff-d5e8c3a85a50c6752bd812dea2b6d26a)
2016-12-20 09:20:44 -05:00
Artem Bilan
f7def2d1de INT-4187: Add enable-status-reader for tailer to XSD
JIRA: https://jira.spring.io/browse/INT-4187
2016-12-19 16:10:16 -05:00
Ali Shahbour
d2f4b27f92 INT-4187: Add enable-status-reader for tailer
JIRA: https://jira.spring.io/browse/INT-4187

Add javadoc and test

- assertTrue on default adapter
- assertFalse check on nativeAdapter
- update XSD to add enable-status-reader

add `@auther`

add example in reference document

update adoc

* Fix minor typos in docs and allow to configure `enable-status-reader` with property placeholder

**Cherry-pick to 4.3.x**

(cherry picked from commit 16c7535)
2016-12-19 15:40:12 -05:00
Artem Bilan
176be69b0f Fix expected messages for the TcpNioConnReadTests
https://build.spring.io/browse/INT-MASTER-475/
https://build.spring.io/browse/INT-MJATS41-850/

**Cherry-pick to 4.3.x**

(cherry picked from commit 44ad811)
2016-12-19 11:09:57 -05:00
Artem Bilan
21d355c538 Assert for another exception in TcpNioConReadTests
https://build.spring.io/browse/INT-MJATS41-847/

**Cherry-pick to 4.3.x**

(cherry picked from commit 968812c)
2016-12-16 12:59:15 -05:00
Artem Bilan
3127f25bfe Fix Race Conditions in TcpNioConnectionReadTests
https://build.spring.io/browse/INT-SI43X-60

After introduction the `sendErrorToListener()` function for the `TcpConnectionSupport`, all the tests in the `TcpNioConnectionReadTests` have flaw to be affected by the race condition to release semaphore in the `onMessage()` and don't get a connection as closed yet.

* Fix the tests adding `CountDownLatch` for the `ErrorMessage` and `AtomicReference` to assert an Exception message afterwards.

**Cherry-pick to 4.3.x**

Add Travis diagnostic to determine what is the difference if that

Revert Travis diagnostic

Looks like would be better to wait for CI failure to determine the root of sporadic cause

Conflicts:
	spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/TcpNioConnectionReadTests.java
2016-12-15 16:47:18 -05:00
Artem Bilan
6a51da65e6 INT-4185: Fix FileReadingMessageSource for Java 6
JIRA: https://jira.spring.io/browse/INT-4185

Even if `WatchEventType` doesn't expose Java 7 API, its instantiation leads to the `StandardWatchEventKinds` object which already isn't Java 6

* Move `this.watchEvents = new WatchEventType[] { WatchEventType.CREATE }` to the ctor and guard it with the `ClassUtils.isPresent("java.nio.file.WatchService")`

Assertions for `WatchService`-based setters
2016-12-15 16:34:44 -05:00
Gary Russell
21ee3c2259 Fix (S)FTP Java/DSL Config
JIRA: https://jira.spring.io/browse/INT-4184

Polishing

(cherry picked from commit cc9d825)
2016-12-14 17:24:44 -05:00
Gary Russell
e8eecc7d8f INT-4183: Add SSL Handshake Timeout for TCP
JIRA: https://jira.spring.io/browse/INT-4183

Previously, this was hard-coded to 30 seconds.

* Fix typos according PR comments

Conflicts:
	spring-integration-ip/src/main/java/org/springframework/integration/ip/config/IpAdapterParserUtils.java
	spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/SocketSupportTests.java

* Resolve conflicts for the  `SocketSupportTests` where `ApplicationEventPublisher` isn't `@FunctionalInterface` yet in SF-4.3.x
2016-12-13 18:54:38 -05:00
Yaron Yamin
e7f93b9e0b INT-4173 Add Query support for Mongo i-c-adapter
JIRA: https://jira.spring.io/browse/INT-4173

INT-4173 convert query-expression to BasicQuery - fix checkstyle violation

INT-4173 convert query-expression to BasicQuery - refactor. address CR comments

INT-4173 convert query-expression to BasicQuery - UT coverage, xsd attribute documentation

INT-4173 cr comments, refactoring, register mongo api package for int-mongo:inbound-channel-adapter query-expression

INT-4173: Documentation, address PR comments & checkstyle violations

Polishing code style and imports order

**Cherry-pick to 4.3.x**

Conflicts:
	spring-integration-mongodb/src/test/java/org/springframework/integration/mongodb/inbound/MongoDbMessageSourceTests.java
2016-12-12 17:15:44 -05:00
Artem Bilan
fa0ba9b84e Turn off beanFactoryReference for Gemfire Caches
Looks like there is some race condition around static fields in the `GemfireBeanFactoryLocator`

Also add `@DirtiesContext` to the `GemfireInboundChannelAdapterTests`

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

(cherry picked from commit 90136d7)
2016-12-01 11:37:24 -05:00
Vedran Pavic
8198ff1861 INT-4178: Retry CannotSerializeTransactionException in JdbcLockRegistry
JIRA: https://jira.spring.io/browse/INT-4178

The `JdbcLockRegistry` does not retry `CannotSerializeTransactionException` thrown by `DefaultLockRepository.acquire` which in turn causes `LockRegistryLeaderInitiator`s thread to get stuck.

* catch `CannotSerializeTransactionException` on `DefaultLockRepository.acquire` and ignore it to ensure a retry

**Cherry-pick to 4.3.x**
2016-12-01 10:36:24 -05:00
Artem Bilan
67332ad93a Fix One More Address already in use Issue
https://build.spring.io/browse/INT-MASTER-350

There are so much other similar `SocketUtils` usage and it doesn't look so quickly to fix them all
Let's do that on demand!
Or just live with rebuild forever to believe that it was just a bad luck...

Fix race condition when we assign the `port` for client before server actually has obtained the real port from OS
2016-12-01 09:27:47 -05:00
Artem Bilan
514e693f49 INT-4176: Fix Gemfire tests
JIRA: https://jira.spring.io/browse/INT-4176

The `DelayerHandlerRescheduleIntegrationTests` doesn't close `context` in the end of test.
That causes clashes for `beanFactoryResolver` in other tests.
When those tests are fail, we come into condition when new processes can't be started/stopped because of effect of non-stopped context

* Fix all the `DelayerHandlerRescheduleIntegrationTests` to stop `context` in the end of test
* Remove unused files in the `gemfire/store` test package
* Add current date value to the `CacheServerProcess` name to avoid clashes with other ran on the same host
* Add NPE check for `region` in the `GemfireMetadataStoreTests`
* Extract `@BeforeClass/@AfterClass` for the `CacheWritingMessageHandlerTests` to start only one Gemfire cache per class

**Cherry-pick to 4.3.x & 4.2.x**
2016-11-30 14:32:13 -05:00