Commit Graph

365 Commits

Author SHA1 Message Date
Gary Russell
93989a0c9b INT-4124: ByteBuffer.array() with Direct Buffers
JIRA: https://jira.spring.io/browse/INT-4124

`ByteBuffer.array()` returns null when Direct.

Change `ChannelInputStream` to use the `ByteBuffer` directly instead of
the underlying `byte[]`.
2016-09-26 22:25:38 -04:00
Artem Bilan
12fb590b95 Mainly Checkstyle Violation Fixes
* Upgrade to Checkstyle `7.1`
* Relax `RequireThis` rule a bit. Right now it does the effort only in case of overlapping. See https://github.com/checkstyle/checkstyle/issues/2362 for more info
* Enable some annotation rules and provide fixes for violations
* Enable `tabs indents` rule. This was the biggest fix in this PR
* Resolve `TODO` in the `MessagingMethodInvokerHelper` and fix tests to meet `IllegalStateException` now

Remain Checkstyle version `6.16.1` and reinstate `RequireThis` rule

The latest Checkstyle has a bug with local scope variables if they have the same names as property.

Revert some literals splitting

Fix some line length exceeding and code style
2016-09-22 13:23:51 -04:00
Artem Bilan
6c6e1d319d INT-4108: Fix idempotency for some Lifecycles
JIRA: https://jira.spring.io/browse/INT-4108

Some `Lifecycle.start()/stop()` usage doesn't ensure robustness for components causing unexpected and difficulty tracing issues

* Fix `Lifecycle.start()/stop()` for `FileReadingMessageSource`, `FileWritingMessageHandler`, `AbstractMqttMessageHandler`
* In the `DefaultHeaderChannelRegistry`, `LockRegistryLeaderInitiator`, `MqttPahoMessageHandler` rework logic for shared variables to avoid `NPE`
* Increase receive timeouts in the `PayloadDeserializingTransformerParserTests` and `UdpChannelAdapterTests`
* Prove with the `WatchServiceDirectoryScannerTests` changes that several invocation for `FileReadingMessageSource.start()` are idempotent

**Cherry-pick to 4.3.x**
2016-09-13 12:09:56 -04:00
Artem Bilan
c2bdaf54a7 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-09-01 13:08:34 -04:00
Gary Russell
1c66b090fb Lambdas - IP Module 2016-08-31 17:04:07 -04:00
Artem Bilan
370be4853d Apply Some Java 8 Code Changes
* Make most functional interfaces as `@FunctionalInterface`
* Convert some abstract classes to `@FunctionalInterface` with `default` methods
* Apply Lambda style implementation in some places
* Remove `Function` in favor of similar in Java 8

*  Remove redundant code from `DefaultAmqpHeaderMapper` since we are already on Spring AMQP-2.0
* Add several ctors to the `ExpressionEvaluatingMessageListProcessor`
* Populate explicit `Boolean.class` `expectedType` from the `ExpressionEvaluatingReleaseStrategy`
2016-08-29 09:14:31 -04:00
Gary Russell
1ecc946f4a Checkstyle Fixes for Previous Commit 2016-08-26 14:40:13 -04:00
Artem Bilan
eaed954458 INT-3913 Remove/resolve deprecation from the past
JIRA: https://jira.spring.io/browse/INT-3913

* Remove deprecated classes and methods/constructors, deprecated XML attributes
* Remove `TcpConnectionEventListeningMessageProducer` and rework tests logic to the `ApplicationEventListeningMessageProducer`
* Fix several typos
* Remove/rework deprecated entities mentioning
2016-08-26 13:42:47 -04:00
Gary Russell
04a42f54be Rename Schemas to 5.0
Fix Schema Imports

spring.schemas
2016-08-18 14:40:38 -04:00
Artem Bilan
28216013dd Fix some typos in IP module (JavaDocs, comments) 2016-08-11 21:39:59 -04:00
Gary Russell
2a66f39df1 TCP/UDP: Use OS to Select Test Ports
https://build.spring.io/browse/INT-AT42SIO-228/
2016-07-29 16:32:38 -04:00
Gary Russell
6eba49c625 INT-4080: Add TcpConnectionFailedEvent
JIRA: https://jira.spring.io/browse/INT-4080
2016-07-26 12:02:14 -04:00
Artem Bilan
a7dc7c3912 INT-4057: Router: don't use convert for Class key
JIRA: https://jira.spring.io/browse/INT-4057

When general router `channelKey` returns just a `Class<?>` result, we end up with the
`unsupported return type for router [class java.lang.Class]` and forced to to call its `getName()` in the target application code before returning to router.

* Change the `AbstractMappingMessageRouter` logic to treat `Class<?>` as a special String-aware case, use its `getName()` and don't go to the `ConversionService`
* Increase receive timeout for replies in the `TcpInboundGatewayTests`
2016-07-11 06:36:21 -04:00
Gary Russell
08718d1919 INT-4047: TCP: Add contentType Header
JIRA: https://jira.spring.io/browse/INT-4047

Polishing - PR Comments
2016-06-07 12:19:26 -04:00
Gary Russell
8e3622757d File Cleanup - Event to JMX 2016-06-04 11:39:43 -04:00
Gary Russell
06a1d503be INT-4029: TCP: Add Buffer Pooling to Deserializers
JIRA: https://jira.spring.io/browse/INT-4029

Support the use of buffer pools in the deserializer code to
allow buffer reuse.
2016-05-11 15:01:17 -04:00
Gary Russell
9e51ba4ea4 INT-4024: TcpNetConnection Do Not Cache Listener
JIRA; https://jira.spring.io/browse/INT-4024

When the `FailOverClientConnectionFactory` is used on top of a
`CachingClientConnectionFactory`, the underlying connection's listener
is changed to the new `CachedConnection` which in turn has its
listener set to the new `FailoverTcpConnection`.

Since the caching connection factory implies single-use (so the connection
is "closed" - returned to the cache), the `FOCCF`
is also forced to have single-use = true - hence the new ultimate listener.

The `TcpNetConnection` obtained its listener (`getListner()`) in the outer
block of its read loop and hence did not detect the listener change.

This caused the old listener (cached connection) to be invoked and when
the result was ultimately passed back to the `TcpOutboundGateway`, the
connection id did not match and the reply eventually timed out.

Change the `TcpNetConnection` to call `getListener()` for every message.

This was already the case in `TcpNioConnection`.
2016-05-10 19:07:08 -04:00
Gary Russell
f0079cefd5 Fix Final "Available Socket" Tests
https://build.spring.io/browse/INT-AT42SIO-141/

Also fix sftp .gitignore
2016-05-03 11:55:55 -04:00
Artem Bilan
818387f0a4 INT-3982: Fix XSD declaration ambiguity
JIRA: https://jira.spring.io/browse/INT-3982

Also fix some sporadic, timing issues in tests
2016-04-19 08:18:14 -04:00
Gary Russell
4027b38da8 Remove System.out/.err Calls From All Tests 2016-04-14 16:22:45 -04:00
Gary Russell
57f96bb759 checkstyle Misc Rules
checkstyle Nesting

checkstyle GenericWhitespace

checkstyle MethodParamPad

checkstyle NoWhiteSpace

checkstyle ParenPad Script

checkstyle ParenPad
2016-04-05 17:21:29 -04:00
Gary Russell
05cc7be644 checkstyle WhiteAround
WhiteAroundCheck script
2016-04-05 13:50:11 -04:00
Gary Russell
842aded9a4 checkstyle MutableException
checkstyle EmptyBlock

checkstyle fixRightCurly Script

checkstyle EmptyStatement

checkstyle RightCurly

checkstyle TailingWhite

checkstyle NeedBraces

Fix the line separator in the `fixRightCurly.gradle`
2016-04-05 13:10:33 -04:00
Gary Russell
4ac3a79df7 checkstyle FinalClassCheck
fixes

fixModifiers after fixFinal

Revert CachingSessionFactory

Class is spied in tests.

checkstyle - Import Rules

checkstyle InterfaceIsType

checkstyle InnerTypeLast

checkstyle OneStatementPerLine

CovariantEquals
OneTopLevelClass

* Revert `'\n'` -> `System.lineSeparator()` in the Gradle scripts to meet Git `autocrlf = true` on Windows
* Fix timing issue with the `LastModifiedFileListFilterTests`, when the `age = 1` might not be enough for the file object when we have some delay before checking
2016-04-04 13:49:56 -04:00
Gary Russell
43af472c3a checkstyle HideUtilityClassConstructor
https://sonar.spring.io/issues/search#componentRoots=org.springframework.integration%3Aspring-integration|createdAt=2016-04-01T10%3A00%3A36%2B0000|sort=UPDATE_DATE|asc=false
2016-04-01 16:18:28 -04:00
Gary Russell
0fd72d2d18 TCP Connection Factory FactoryBean Improvements
Add ctor argument so that early `getObjectType()` calls can return
a narrower type (server Vs. client CF).
2016-03-25 14:00:00 -04:00
Artem Bilan
2b0598291c RequireThis rule and fixThis Gradle task
* `gradlew clean check -x test --parallel --continue` - to collect reports
* `gradlew fixThis --parallel` - to fix all possible vulnerabilities. With `-Dfile.encoding=UTF-8` on Windows

Since the `RequireThisCheck` doesn't see parents for anonymous classes (e.g. `Runnable` callback), its report doesn't contains the outer class name with `this.`,
therefore we still have to fix those cases manually.
Thanks to the wrong `replacer` just with `this.` we have uncompilable code enough easy to find problems.
Not so easy to fix for good readability though...

* Upgrade to Grade 2.12
* Upgrade to SonarQube native plugin

The fix contains at about 300 files. So, will be done on merge.

Fix `fixThis.gradle` according PR comments

Apply `fixThis` and also `fixModifiers` for test classes.
 Fix some `this.` inner issues manually.
 Make code polishing for long lines after `fixThis`

Fix conflicts and vulnerabilities after the rebase
2016-03-22 20:18:27 -04:00
Artem Bilan
66cd92a6e7 INT-3964: More @EnableIntegration Documentation
JIRA: https://jira.spring.io/browse/INT-3964

Doc Polish

XSD: document classes for element implementations

Fix Redis XSD typo for CDATA
2016-03-22 10:41:07 -04:00
Artem Bilan
c2954881ad Enable RedundantModifier checkstyle, add fixer
Add `fixModifiers.gradle` to run after `check` task.

The `RedundantModifierChecker` doesn't catch all errors at once.
We need run `check -> fixModifiers` pair several times to reach `SUCCESSFUL`.

The `fixThis` has been ported from the SA, but without applying.

* Polishing for `fixModifiers.gradle`
* Fix all redundant modifier with the `fixModifiers.gradle`

NOTE: Since all these task modify files on Windows we have to run them with the `-Dfile.encoding=UTF-8`.
Otherwise they are read and write with the Windows default `cp1251` making them incompatible with Unix system.
2016-03-17 13:10:05 -04:00
Artem Bilan
ef40a939cf Add check header rule and fixHeaders task
Add "new line" in the header end

* Optimization for the `fixHeaders.gradle`
* Apply the `fixHeaders` for the affected classes
2016-03-07 15:08:51 -05:00
Gary Russell
d48597f41b Fix TCP Cache Race Condition
On a gateway remote timeout, there's a race between the reader and writer
thread to close the connection.

Change the `released` boolean to an `AtomicBoolean` to avoid the unexpected
exception when the other thread attempts to return a non-existent connection
to the pool.
2016-02-16 15:51:54 -05:00
Gary Russell
91387147c9 INT-3952: Local IP Address Header and SocketInfo
JIRA: https://jira.spring.io/browse/INT-3952
2016-02-11 11:43:28 -05:00
Gary Russell
d8ad38d8ea INT-3869: Fix MBeanServer Detection
JIRA: https://jira.spring.io/browse/INT-3869

When using `@EnableIntegrationMBeanExport` with no `server` property,
the `IntegrationMBeanExportConfiguration` incorrectly created a new
`MBeanServer` instead of attempting to locate an existing one.

Use the `SpecificPlatform` logic from `MBeanExportConfiguration` to locate
a specific server on `WebSphere` and `WebLogic`; otherwise defer to
`JmxUtils.locateMBeanServer()` in the exporter's initialization method.

Add a test to verify the same server is used in multiple contexts.

* Fix `ConnectionFactoryTests` regarding new `MessageProducerSupport` logic
2016-01-12 15:58:21 -05:00
Artem Bilan
74cbc58698 INT-3926: Add <poller> for all outbound tags
JIRA: https://jira.spring.io/browse/INT-3926

* Add `<poller>` for all `<outbound-adapter(gateway)>`
* Add/modify tests for `<queue>` as an input channel and particular `<poller>`
* Move XSD from the `xml` package to the `config` level to achieve the consistency throughout the project.
2016-01-07 12:16:40 -05:00
Marcin Pilaczynski
8bf8caa22e INT-3883: UDP: destination and socket expressions
JIRA: https://jira.spring.io/browse/INT-3883

UDP Outbound Channel Adapter is able to use given UDP Inbound Adapters
server socket (outgoing packets will have source port same as incoming
packets destination port).

* Introduce `destinationExpression` instead of hard-coded `host/port` logic in the `DatagramPacketMessageMapper`
* Make `UnicastSendingMessageHandler.destinationExpression` mutually exclusive with `host/port` pair
* Move `socketExpression` to the setter as it is absolutely different option from the `destination`
* Make `UnicastSendingMessageHandler` expressions logic based on the `requestMessage`

INT-3883 Code review fixes.

Further polishing

Polishing according PR comments

Rework the String socket address logic just to the expected `URI` style.
Accept `2016` for changed classes.
2016-01-04 14:31:40 -05:00
Artem Bilan
287173bc67 Fix TCP tests to use 0 port
https://build.spring.io/browse/INT-MJATS41-495
https://build.spring.io/browse/INT-AT42SIO-16

Can be backported to `4.2.x` on demand
2015-12-28 18:22:07 -05:00
Gary Russell
ed874ea84a TCP ConnectionFactoryTests Race Condition
Wait for events.
2015-12-21 11:38:55 -05:00
Gary Russell
0458220756 TCP ConnectionFactoryTests Diagnostics
https://build.spring.io/browse/INT-SONAR-1582/
2015-12-20 16:07:01 -05:00
Gary Russell
180ada63b0 INT-3912: TCP Server Listening Event
JIRA: https://jira.spring.io/browse/INT-3912

Polishing - PR Comments
2015-12-15 10:15:13 -05:00
Artem Bilan
471d08250d Add MulticastRule to Check the NIC for Tests
Add `skip` variable

Polishing

Tests failed after installing VirtualBox.

Further polishing to skip `vboxnet` NICs.

Also explicitly set the multicast socket `interface` (instead of `networkInterface`)
to address a specic IPAddress if a NIC has multiple bindings.

Add `@MulticastRule` to `DatagramPacketMulticastSendingHandlerTests` (separate into
new test file).

Fix tests to use the rule's NIC.
2015-12-14 18:17:27 -05:00
Artem Bilan
cf528c0b5d INT-3665: Remove Deprecations and Resolve Issues
https://jira.spring.io/browse/INT-3665

Fixes according Travis report

Introduce `...ExpressionString(String)` setter

Some further fixes and polishing

Address PR comments
2015-12-08 16:48:29 -05:00
Gary Russell
d16cd9748c INT-799: Remove Core Deps from s-i-test
JIRA: https://jira.spring.io/browse/INT-799

Some test classes (e.g. `TestUtils`) were duplicated in core to avoid cyclic
dependency.

Now that core messaging has been moved to spring-messaging, it is possible
to remove the dependencies on `spring-integration-core` from `spring-integration-test`.

A few minor test cases have been moved to `spring-integration-core`.

The simple polishing to the `build.gradle` and `ServiceActivatorOnMockitoMockTests`
2015-12-07 20:39:00 -05:00
Gary Russell
255247ca9a Code Polishing (Sonar)
- remove redundant modifiers
- overridable methods called from ctors

Polishing - PR Comments
2015-12-07 15:39:13 -05:00
Gary Russell
c0ca5a9b89 INT-3894: Polishing
Remove IPv4 from build.gradle.
Fix race for ackPort.
2015-11-24 11:35:43 -05:00
Gary Russell
b4218982da INT-3984: UDP: OS Selected Server Port
JIRA: https://jira.spring.io/browse/INT-3894

Allow UDP server port (and sender Ack port) to be selected by the operating system.

Also fix multicast tests to run on all platforms.

Change tests to use OS selected port.
2015-11-23 17:16:23 -05:00
Artem Bilan
b621417380 INT-3893: UnicastReceivingChannelAdapter: fix NPE
JIRA: https://jira.spring.io/browse/INT-3893

Polishing

Send on the calling thread if the executor is shut down.
2015-11-20 10:52:07 -05:00
Gary Russell
051b393ed0 Prepare Master for 4.3
Reference to 4.3

Refactor `what's new` for 4.3
2015-11-17 12:12:49 -05:00
Artem Bilan
9d8e2b61f6 Fixes for Sporadic Test Failures
* `ClientWebSocketContainer`: add some synchronization to avoid race conditions: https://build.spring.io/browse/INT-B41-492
* `TomcatWebSocketTestServer`: convert to `0` port to rely on the OS resolution for `localPort`
* Add `LogAdjustingTestSupport` for STOMP test
* `SftpServerTests`: use `0` port to rely on the OS resolution for `localPort`
* `ImapMailReceiver`, `OutboundGatewayFunctionTests` (JMS), `CachingClientConnectionFactoryTests`,
`AsyncGatewayTests`, `AsyncMessagingTemplateTests`, `GatewayParserTests`, `PriorityChannelTests`, `AggregatorIntegrationTests`: increase timeout
* `EnableIntegrationTests`: use `LogAdjustingTestSupport`
* `FileOutboundChannelAdapterParserTests`: rework `Thread.sleep()` with `CountDownLatch`
* `ConnectionToConnectionTests`: increase timeout and count iteration. Previously with `1sec` we may lose some events. And we can't just rely on the `10sec`,
because the last iteration will be so long
* `TcpOutboundGatewayTests`: `500ms` is so big timeout to wait for the `Exception` that in the high load environment we can yield to other Thread so long.
Like in our case to `server` Thread to send the reply for us. Therefore decrease the Exception timeout to the `50ms` and increase server delay to `2sec`
* `StompInboundChannelAdapterWebSocketIntegrationTests`: remove `@Qualifier("taskScheduler")` as a potential candidate to test against latest SF changes.
We're fine with `SF-4.2.2` and it is just a test-case. So, I don't see reason to wait for their fix here.

STOMP: `session = null` in adapters for any transportError

Polishing
2015-11-14 16:12:23 -05:00
Gary Russell
e5269bb265 INT-3886: TCP Fix Socket Timeout: Raw Deserializer
JIRA: https://jira.spring.io/browse/INT-3886

An SO user reported a short message delivery when an NIO connection was timed out.

See JIRA for link.

We could not produce the problem with his deserializer but it did identify a problem
with the standard `ByteArrayRawSerializer`.

With NIO, socket timeouts were reported to the deserializer as a normal EOF (-1). This
caused the raw serializer to emit a short message - it's signal for end of message is the
socket closure.

We can't treat a timeout as a normal EOF.

If the socket is forcibly timed out due to no recent data, throw a `SocketTimeoutException` to
the deserializer.

Just in case the old behavior is being relied upon, a boolean has been added to restore that
behavior. This is not recommended, as using timeout to delimit messages is not reliable.

* Fix typos
* Increase `MongoDbInboundChannelAdapterIntegrationTests` timeouts
* Some code polishing
2015-11-12 21:35:03 -05:00
Gary Russell
1849cda1c1 Extract LogAdjustingTestSupport
Also add test debugging to JmsOutboundGatewayTests.
2015-11-07 11:06:19 -05:00