Commit Graph

6910 Commits

Author SHA1 Message Date
Gary Russell
a6c8ba74b7 INT-2890 Remove Hard-Coded Port from HTTP Tests
Conflicts with other ports on build server.

Use SocketUtils to find an available port.
2013-01-22 15:20:58 -05:00
Mark Fisher
11e303744e Merge pull request #708 from garyrussell/INT-2886
* INT-2886: Fix TCP Connection Exception
2013-01-22 15:16:20 -05:00
Gary Russell
e72b101c52 INT-2886 Fix TCP Connection Exception
When an exception occurred while obtaining a connection,
the root cause was lost.

In addition, a MessageMappingException was thrown instead
of a MessageHandlingException.

- Deprecate getConnection() in favor of obtainConnection()
- Capture the underlying exception as the cause of a MessageHandlingException
- Add test case

fixed @link (when merging)

removed @return with no args (when merging)
2013-01-22 15:10:24 -05:00
Mark Fisher
3245fa58dc Merge pull request #698 from garyrussell/INT-2860
* INT-2860: Improve TCP Connection Timeout
2013-01-22 14:29:43 -05:00
Gary Russell
e4722de464 INT-2860 Improve TCP Connection Timeout
A connection used by a gateway may timeout prematurely.

Previously, the socket read timeout simply controlled when
a socket would be closed after the timeout occurred.

Consider a connection with so-timeout set to 10 seconds; the
application initializes at T+0 and the first message is sent,
with the server responding immediately; the timeout clock starts.
Next, a message is sent at T+5 to a service that takes 6 seconds
to respond. The connection will timeout at T+10 before the
response is received; the socket is closed and client does not
receive the response.

The solution is to wait 2 timeout cycles *IF* a message has
been sent within the current timeout.

Maintain a timer for the last send() operation. When a socket
timeout occurs, examine the last sent time; if within the
timeout, defer the close until the next timeout.

We cannot simply rely on the last send time because, when
using collaborating adapters, continuous sends (with no replies)
would defer the close indefinitely. Hence, the second test looking
to see if we have not had a successful read for the last 2 timeouts.

NIO does not directly support socket timeouts (because there is no
thread hanging on the read); instead, the timeout logic is
performed on the selector thread.

Rename DefaultTimeoutTests to ConnectionTimeoutTests.

Add tests (for both Socket and NIO connections) to assert the correct
operation when a send is performed within a timeout, as well as
when the server takes > 2x the timeout to respond.

INT-2860 Fix Typo in Exception Message

Error sending meeeage.

removed invalid comment from test (while merging)
2013-01-22 14:23:23 -05:00
Mark Fisher
be29f909ba Merge pull request #695 from garyrussell/INT-2861-2862
* INT-2861-2862:
  INT-2861/INT-2862 TCP Outbound Gateway Fixes
2013-01-22 12:30:51 -05:00
Gary Russell
90132686ae INT-2861/INT-2862 TCP Outbound Gateway Fixes
INT-2861

Close connection after 'remoteTimeout' because the
socket is dirty (may contain an in-flight reply).

Add test that demonstrates the problem and that it
is resolved.

INT-2862

Remove entries from pendingReplies (map of async responses
for which we are waiting).

Add an assertion to the above test to ensure cleanup.
2013-01-22 12:28:48 -05:00
Mark Fisher
e66a098149 Merge pull request #710 from garyrussell/INT-2889
* INT-2889: Fix Concurrency Problem in Type Converter
2013-01-18 15:36:47 -05:00
Gary Russell
1e9581b3a5 INT-2889 Fix Concurrency Problem in Type Converter
In the BeanFactoryTypeConverter, when falling
back to a PropertyEditor (when the source is non-
String and the target is String), the setValue() and getAsText()
methods are used.

This is not thread-safe and one thread might get another's
converted value.

Synchronize the use of the PropertyEditor.

Add test, that reliably reproduces the problem, to verify the
fix.
2013-01-18 15:31:21 -05:00
Gunnar Hillert
f3772914f2 Merge pull request #701 from garyrussell/INT-2838
* garyrussell-INT-2838:
  INT-2838 Allow @bean Expressions in (S)FTP Out
2013-01-18 13:01:36 -05:00
Gary Russell
969b3bec27 INT-2838 Allow @bean Expressions in (S)FTP Out
The message processors previously did not have a bean resolver.

* Add the bean factory
* Add tests
2013-01-18 12:57:27 -05:00
Gunnar Hillert
58a5fa3be8 Merge pull request #706 from garyrussell/INT-2864
* garyrussell-INT-2864:
  INT-2864 Enforce Ref/Expression Mutual Exclusivity
2013-01-18 12:48:01 -05:00
Gary Russell
dd6af7b387 INT-2864 Enforce Ref/Expression Mutual Exclusivity
Delegating consumer endpoints (<service-activator/> etc)
may not have both 'expression' and 'ref' attributes.
Previously, 'expression' was ignored when 'ref' was present.

- Enforce mutual exclusivity in AbstractDelegatingEndpointParser.
- Add tests for illegal combinations.
- Improve error message when 'method' used with <expression/>.
- Change parser to use reader.error() instead of Assert.
- Add element description to all parser errors.
2013-01-18 11:56:00 -05:00
Gary Russell
e64a167479 INT-2885 Remove DOS Newlines
MessageGroupStoreReaper
2013-01-16 13:37:22 -05:00
Gary Russell
05021f1e24 Merge pull request #705 from artembilan/INT-2880 2013-01-16 13:12:49 -05:00
Artem Bilan
03053a8450 INT-2880 Fix System.out Concurrent Race Condition
Gradle may run tests using multiple threads.

Using shared resources (e.g. `System.out`) may produce concurrency issues.

* Remove usage of `System.out`
* Add mocking around `LoggingHandler#messageLogger`.

JIRA: https://jira.springsource.org/browse/INT-2880
2013-01-16 13:10:54 -05:00
Gary Russell
3b2489ea3e Merge pull request #704 from artembilan/INT-2878 2013-01-16 12:55:07 -05:00
Artem Bilan
2a419ba6d8 INT-2878: MessageGroupStoreReaper's Lifecycle Fix
`MessageGroupStoreReaper` continues to expire `MessageGroups` via `scheduled-task`
when not `running`.

* Add check `isRunning()` to `run()` & `destroy()`
* Additional `MessageGroupStoreReaper` polishing
* Add test-case

JIRA: https://jira.springsource.org/browse/INT-2878

INT-2878: Polishing : PR Comments
2013-01-16 12:54:22 -05:00
Gary Russell
b48bed486f INT-2868 Fix SSL Key Store Resource Handling
Documentation indicates that the keystore and truststore
arguments can be resource patterns (file:..., classpath:..., etc)
but the code always used a ClasspathResource.

Use a PathMatchingResourcePatternResolver to interpret the
pattern correctly.

Add tests.
2013-01-16 12:39:12 -05:00
Gary Russell
df6a8dee04 Merge pull request #693 from artembilan/INT-2858 2013-01-16 12:06:13 -05:00
Artem Bilan
a994b40b47 INT-2858: Fix for Repeatable invocation.proceed()
Heretofore there wasn't ability to make some scenario like this, when we want to make failure notification on each retry:

<service-activator>
  <request-handler-advice-chain>
      <bean class="org.springframework.integration.handler.advice.RequestHandlerRetryAdvice"/>
      <bean class="org.springframework.integration.handler.advice.ExpressionEvaluatingRequestHandlerAdvice"
	    p:onFailureExpression="#exception" p:failureChannel-ref="errorOnEachRetryChannel"/>
  </request-handler-advice-chain>
</service-activator>

The second Advice was invoked only once. This was because `ProxyMethodInvocation` keeps the index of current interceptor
on each `invocation.proceed()`, which is recursive by design.

So, change `AbstractRequestHandlerAdvice` to use `((ProxyMethodInvocation) invocation).invocableClone().proceed();`
This way, we get a fresh `MethodInvocation` for the current `Advice` with nested desired advices.

JIRA: https://jira.springsource.org/browse/INT-2858

INT-2858: Polishing; PR Comments

Introduce `AbstractRequestHandlerAdvice.ExecutionCallback#cloneAndExecute()` especially for repeatable Advices, e.g. `RequestHandlerRetryAdvice`
to avoid overhead from `clone()` on simple Advices

INT-2858: Doc ExecutionCallback#cloneAndExecute()

INT-2858 Polishing

Rework docs; add Javadoc; add to test case.
2013-01-16 12:04:03 -05:00
Gunnar Hillert
0ff2a2027b Merge pull request #700 from garyrussell/INT-2875
* garyrussell-INT-2875:
  INT-2875 Fix CPU Usage In JMS Test
2013-01-15 15:24:23 -05:00
Gary Russell
c958b243d3 INT-2875 Fix CPU Usage In JMS Test
Reply Container was spinning receiving StubMessages.

Set auto-startup to false on the gateways configured with
a <reply-listener/>.
2013-01-15 15:11:02 -05:00
Gary Russell
f3b1c9d9d2 Merge pull request #696 from ferstl/INT-2863 2013-01-15 13:15:32 -05:00
Stefan Ferstl
f9aea7d5f5 INT-2863 Add Release Strategy to Resequencer
- allow the configuration of release strategies on resequencers
-- adjust the xsd to allow the definition of a release strategy
-- move release strategy parsing to AbstractCorrelatingMessageHandlerParser
-- add unit tests

For reference see: https://jira.springsource.org/browse/INT-2863

INT-2863 Polishing

Fix white space; add @author; update copyright.

INT-2863 Resequencer/Aggregator Docs

Add docs for correlation and release strategis to Resequencer.

Add *.expression docs to Aggregator.
2013-01-15 13:04:56 -05:00
Gunnar Hillert
3c59d377f4 Merge pull request #703 from garyrussell/INT-2847
* garyrussell-INT-2847:
  INT-2847 Fix Test with Java 7
2013-01-14 23:50:27 -05:00
Gary Russell
ef48e6ad10 INT-2847 Fix Test with Java 7
Java 7 stores the comparator directly in the PriorityBlockingQueue
rather than in a nested PriorityQueue as in earlier JDKs.
2013-01-14 23:48:38 -05:00
Gary Russell
bcaf11c3f8 Merge pull request #694 from dturanski/INT-2859 2013-01-14 12:07:40 -05:00
David Turanski
50bea87e0e INT-2859 Fix Python OOM Error
INT-2859 - Remove Unnecessary Guard Condition
2013-01-14 12:06:20 -05:00
Gary Russell
0cbde92b5a Merge pull request #691 from artembilan/INT-2845 2013-01-14 10:48:26 -05:00
Artem Bilan
2bc3ecb9d7 INT-2845: Gradle: Check XSD Versions in Tests
In many cases IDEs import into test configs Namespace-resources
with hardcoded versions of Spring & Spring Integration XSDs.

This may produce build issues with different Spring versions.

It also causes an issue during the transition to a new Spring Integration version (e.g. 3.0).

* Add Gradle task 'checkTestConfigs' to check test configs for hardcoded resources' versions.
* Add to 'test' task dependency on new task 'checkTestConfigs'
* Fix hadrcoded versions in the test configs.

JIRA: https://jira.springsource.org/browse/INT-2845
2013-01-14 10:45:03 -05:00
Gary Russell
a80c6e9ce6 Merge pull request #692 from artembilan/INT-2846 2012-12-03 08:57:54 -05:00
Artem Bilan
24bdd39790 INT-2846: ImapMailReceiverTests: fix OS newLine
* Add `trim()` to the actual value
* Remove '\n' from expected value
* Remove redundant Mocks

JIRA: https://jira.springsource.org/browse/INT-2846
2012-12-03 12:40:21 +02:00
Gary Russell
2d6239edd1 INT-2844 Fix Http Test If Building With Spring 3.0
In Spring 3.1, DefaultResponseErrorHandler.getResponseBody() is
tolerant of a null InputStream on the response. With Spring 3.0
a null response causes an assertion exception.

The mock in the tests was not set up to return an InputStream
and so the test failed when building with Spring 3.0.

Configure the mock to return an empty InputStream.

Also added a text response to response.getStatusText().

Tested with Spring 3.0 and 3.1.
2012-12-01 14:08:57 -05:00
Spring Buildmaster
4f606d9c46 [artifactory-release] Next development version 2012-11-30 14:25:59 -08:00
Spring Buildmaster
d195747c4b [artifactory-release] Release version 2.2.0.RELEASE 2012-11-30 14:25:48 -08:00
Mark Fisher
675dc4cf60 Merge pull request #689 from ghillert/INT-2843
* INT-2843: Doc: with 2.2 Java serialization over HTTP not enabled by default

* INT-2842: Doc: Re-order 'What's New in 2.2' section
2012-11-30 16:19:59 -05:00
Gunnar Hillert
37ad09ab55 INT-2843 - Document that with 2.2 Java serialization over HTTP is not enabled by default
INT-2842 - Doc: Re-order 'What's New in 2.2' section

For reference see:

* https://jira.springsource.org/browse/INT-2842
* https://jira.springsource.org/browse/INT-2843
2012-11-30 16:05:30 -05:00
Gary Russell
3d0ffd2e7b INT-2833 Fix Test Race Condition
Empty message group expiry used a < test instead of <=. This caused
the group in the test to be not deleted when it was expected to be.
2012-11-30 15:56:21 -05:00
Mark Fisher
120410f78c Merge pull request #683 from garyrussell/INT-2832-2833
* INT-2832-2833:
  INT-2832/2833 Aggregator Fix and Documentation
2012-11-30 15:38:57 -05:00
Gary Russell
3ea05576b3 INT-2832/2833 Aggregator Fix and Documentation
Expire empty groups.

Due to indentation changes, the code changes look more extensive
than they are. In effect the if (group.size() > 0) test is moved
to a narrower scope and the remove(group) is now performed if the
group is empty.

Document expire-groups-upon-completion.

INT-2832 Doc Polishing

PR Review + punctuation.

INT-2833 Add Delay For Expiring Empty Groups

minimumTimeoutForEmptyGroups
2012-11-30 15:31:36 -05:00
Mark Fisher
84f4bea5e7 Merge pull request #685 from garyrussell/INT-2837a
* INT-2837a:
  INT-2837 Fix Accept Hdr for Serializable Response
2012-11-30 13:59:01 -05:00
Gary Russell
7ef66e2e3f INT-2837 Fix Accept Hdr for Serializable Response
When the expected-response-type was Serializable,
no Accept: header was added.

The SerializingHttpMessageConverter overrides
canRead() from the superclass.

The superclass method allows null in the mediaType
parameter to return true. RestTemplate.AcceptHeaderRequestCallback
calls canRead() with null in the mediaType, preventing
the Accept header from being completed.

Remove the overridden method.

INT-2837 Disable Java Serialization over Http

Previously, Java serialization was enabled by default by
adding the SerializingHttpMessageConverter to the converter
lists (inbound and outbound endpoints). However, there was
a problem in that the Accept header was not set properly on
outbound requests.

Correcting the header could cause other side effects, such as
existing JSON applications using Java serialization instead.

It was felt that it would be safest to disable Java serialization
by default, while retaining the ability to use Java serialization
by explicitly configuring the message converter.

Update tests to deal with the fact the converter is not
configured by default.

INT-2837 Fix Schema Version in Test

Inadvertently added a spring 3.1 schema version.
2012-11-30 13:40:58 -05:00
Mark Fisher
4ce08ad6dc Merge pull request #688 from ghillert/INT-2841
* INT-2841: Fix broken links
2012-11-30 12:04:38 -05:00
Gunnar Hillert
a54312dc6f INT-2841 - Fix broken links 2012-11-30 12:03:12 -05:00
Mark Fisher
28fa4407b9 Merge pull request #687 from ghillert/INT-2840
* INT-2840: Fix build failure against Spring 3.0.7

For reference see: https://jira.springsource.org/browse/INT-2840
2012-11-30 11:56:55 -05:00
Gunnar Hillert
911ddc11af INT-2840 - Fix build failure against Spring 3.0.7
For reference see: https://jira.springsource.org/browse/INT-2840
2012-11-30 00:09:51 -05:00
Gary Russell
734eae72a7 INT-2839 Fix Test Race Condition
A secondary part of the new gateway test was to ensure we
reused the cached connection. However, there was a race condition
in that the connection may not yet have been returned to the pool
by the reader thread that received the response.
2012-11-29 21:30:52 -05:00
Mark Fisher
3d04e15fd3 Merge pull request #686 from garyrussell/INT-2839
* INT-2839: Fix TCP Caching Connections with Gateways
2012-11-29 21:06:39 -05:00
Gary Russell
32251bf6f2 INT-2839 Fix TCP Caching Connections with Gateways
Using the CachingClientConnectionFactory with a gateway
doesn't work. The Listener (gateway) was not being set up
properly by the wrapper. Instead, the actualListener in the
wrapped connection was set to null. This caused the connection
to "close" itself (return to the pool) immediately after the send.

In addition, even with the actualListener set up to properly
reference the gateway, it still wouldn't work because the
gateway can't correlate the reply (the cached connectionId is
prefixed with "cached:" so the gateway can't find the reply.

Further, when onMessage() returned, it caused the reader loop
to end.

Fixes:

1. Properly set up the cached connection with the real listener
so that ultimately the underlying connection sees there is an
actualListener and so doesn't close itself after the send.
2. Override getListener() on the cached connection to return the
real listener.
3. Override onMessage() in order to fix up the connection id in
the message, and return true (intercepted) so the connection doesn't
close itself (terminate the reader thread).
4. close() (return to the pool) after invoking the gateway's
onMessage().
5. Add test cases to verify proper operation including an assertion
that the pooled connection is reused.

This is made a little more complex by the tangle between
connections and connection interceptors; mainly because single-use
connections close themselves after use. This will be addressed in
3.0 (INT-2829) making connection interceptors simpler.
2012-11-29 15:17:24 -05:00