Commit Graph

390 Commits

Author SHA1 Message Date
Artem Bilan
93d7c58b64 Enable ModifierOrderCheck Checkstyle rule (#2673)
* Enable ModifierOrderCheck Checkstyle rule

* Fix violations for `static` and `abstract` modifier
* Remove redundant code in the `TcpNioConnection`
* Mark `connectionFactoryName` as `@Nullable` in the `TcpConnectionSupport`
ctor and its inheritors
* Fix some smells according IDEA suggestions in the affected classes
* This should fix some Sonar smells as well

* * Fix `HeaderMapperTests`

* * Polishing `TcpConnection` code style and fix Javdocs
2018-12-20 19:19:47 -05:00
Gary Russell
4760c54097 Sonar Fixes
Critical smells `o.s.i.h*`.
2018-12-07 12:39:19 -05:00
Artem Bilan
3d696ef068 INT-4554: Fix HTTP Inbound Gateway for multipart
JIRA: https://jira.spring.io/browse/INT-4554
2018-11-15 13:44:57 -05:00
Artem Bilan
6902fd906d Fix Checkstyle violation from previous commit
https://build.spring.io/browse/INT-MASTER-1274/
2018-11-12 10:13:10 -05:00
Gary Russell
fb5854c480 Fix new Sonar reports 2018-11-12 10:03:54 -05:00
Gary Russell
433ef4c4aa Address Sonar reports for recent commits 2018-11-08 13:08:53 -05:00
Artem Bilan
648aeb8e96 Unable ImportOrder Checkstyle rule for tests
* Fix wrong import order in tests
* Polishing for not closed application contexts
* Use diamonds
* Use proper assertion operators
* Remove redundant classes
* Improve performance in JPA tests
* Fix typos
2018-11-07 15:32:31 -05:00
Artem Bilan
262e624ef4 INT-4479: RequestEntity as root for status code
JIRA: https://jira.spring.io/browse/INT-4479

For better user experience expose a `RequestEntity<?>` as a root object
for evaluation context for `statusCodeExpression` execution
2018-10-04 17:23:59 -04:00
Gary Russell
5ab7d24934 Make Headers PREFIX Constants Public
**cherry-pick to 5.0.x**

* Make `IpHeaders` prefix as `public` as well
2018-08-27 16:44:49 -04:00
Artem Bilan
5e47a6a9c4 INT-4517: Refactor beans in IntegrationRegistrar (#2537)
* INT-4517: Refactor beans in IntegrationRegistrar

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

The `IntegrationRegistrar` populates beans into the application context
too early and when the `allowBeanDefinitionsOverride` is disabled we
end up with the `BeanDefinitionOverrideException` just because end-user
beans are applied later.

* Move most of the bean definitions which can be overridden in the target
application from the `IntegrationRegistrar` into the
`DefaultConfiguringBeanFactoryPostProcessor`
* Revise their registration logic to be sure that some of them are
registered only once in the parent context nad others are registered
in the child context as well
* Refactor a `DslIntegrationConfigurationInitializer` do not register
an `IntegrationFlowDefinition.ReplyProducerCleaner` in the child context
one more time: it doesn't bring any local store within the current
child context
* Introduce a `NoBeansOverrideAnnotationConfigContextLoader` in tests
to ensure that in some test-cases we disallow an
`allowBeanDefinitionsOverride` as it is now in Spring Boot since it is
enabled by default in the Spring Framework

* Revernt DslIntegrationConfigurationInitializer changes

Regsiter all the required infrastructure beans in all the application
contexts to avoid class loader issue for `static` store access
2018-08-15 14:18:10 -04:00
Oleksii Komlyk
865e2162e5 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**
2018-07-24 16:12:39 -04:00
Artem Bilan
ee501c801f INT-4436: Register HTTP endpoints at runtime
JIRA: https://jira.spring.io/browse/INT-4436

* Fix `IntegrationRequestMappingHandlerMapping` and
`IntegrationRequestMappingHandlerMapping` to implement a
`DestructionAwareBeanPostProcessor` to allow to register and
destroy HTTP endpoints at runtime, e.g. via `IntegrationFlowContext`
with the dynamic `IntegrationFlow`s
2018-06-25 17:11:23 -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
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
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
10120cdf56 Upgrade to Spring Data Kay.SR4, Security 5.0.2
Remove deprecated method from security tests.
2018-02-20 08:44:33 -05:00
Artem Bilan
11240be555 GH-2358: Register IntGraphController for WebFlux
Fixes https://github.com/spring-projects/spring-integration/issues/2358

The WebFlux on the server side can deal with MVC `@Controllers` as well
without any Servlet environment.

* Enable `IntegrationGraphController` when we not only in the
Servlet environment, but also in the WebFlux
* Upgrade to SF-5.0.4 and fix WebFlux tests to meet the latest requirements
  (https://jira.spring.io/browse/SPR-16337)
* Move `WEB_FLUX_PRESENT` to the `HttpContextUtils`;
deprecate it in the `WebFluxContextUtils`
* Mention WebFlux ability for the `IntegrationGraphController` in the
`graph.adoc`
2018-02-14 11:08:57 -05:00
Gary Russell
3bd4930813 Fix UDP Tangles
- Class tangle in new event
- Package tangle udp <-> util

* Fix JacksonJsonUtils class tangle

* Fix HTTP class tangle
2018-02-01 15:12:53 -05:00
Artem Bilan
30450c48be INT-4376: Upgage to Log4J 2 (#2321)
* INT-4376: Upgage to Log4J 2

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

* Deprecate Log4J 1.x components in favor of newly added
a `Log4j2LevelAdjuster` JUnit `@Rule`
* Update all the logging configuration to Log4J 2

* Polishing after testing
2018-01-11 10:59:55 -05:00
Artem Bilan
d76af8c2aa Fix HTTP module for proper RFC date formats
* Copy data format algorithm from the Spring Web `HttpHeaders` into the
`DefaultHttpHeaderMapper`
* Fix `HttpProxyScenarioTests` for proper zoned date formatting
2017-11-02 10:01:35 -04:00
Artem Bilan
2712e28074 Upgrade to Spring Security 5.0.0.RC1
Remove usage of deprecated `NoOpPasswordEncoder` in favor of
`User.withDefaultPasswordEncoder()` in tests
2017-10-30 20:54:40 -04:00
Artem Bilan
6d96914c1f INT-4350: Handle ResponseEntity in HTTP Inbounds
JIRA: https://jira.spring.io/browse/INT-4350

Spring MVC and Spring WebFlux handles `ResponseEntity` via appropriate
`ReturnValue` handlers.
This way all the headers and status code are fully up to end-user.
The body is handled by the appropriate converter/writer as before

* Add `ResponseEntity` handling to the `HttpRequestHandlingMessagingGateway`
and `WebFluxInboundEndpoint`.
The logic mostly compy/pasted from the `ResponseEntityResultHandler`
2017-10-30 12:05:25 -04:00
Artem Bilan
efb8f04465 Some upgrades and fixes
* Upgrade to SF-5.0.1, Reactor-3.1.1, some other minor upgrades
* Fix `HttpDslTests` and `WebFluxDslTests` for the latest SS compatibility
* Fix JavaDoc in the `ChannelMessageStorePreparedStatementSetter`
2017-10-25 10:52:47 -04:00
Gary Russell
bea5706e67 Fix HTTP For Latest Spring Framework
https://build.spring.io/browse/INT-FATS5IC-277/

Fix mock for request.getRawStatusCode()

4cbef27f90

Also excluded transitive SF dependencies from spring-security.
2017-09-25 10:35:08 -04:00
Artem Bilan
6dad473219 Demonstrate error handling in the HttpDslTests
StackOverflow https://stackoverflow.com/questions/45627072/spring-integration-preserve-http-error-code-and-body-in-response
2017-08-11 13:45:51 -04:00
Artem Bilan
84d60f4ab4 INT-4315: Add WebFlux module
JIRA: https://jira.spring.io/browse/INT-4315

Move Reactive components outside of HTTP module to the new WebFlux one,
including XSD, tests and documentation
Make an appropriate polishing for the `http.adoc` with cross-link
to the `webflux.adoc`

Exclude transitive `spring-webmvc` for the `spring-integration-webflux`
2017-08-11 13:38:37 -04:00
Artem Bilan
6aca63806f Upgrade to the latest SF, SS and Reactor
https://build.spring.io/browse/INT-FATS5IC-249
2017-08-03 19:23:35 -04:00
Artem Bilan
d4a99919ed INT-4300: Add WebFlux Server Support
JIRA: https://jira.spring.io/browse/INT-4300

* Add `ReactiveHttpInboundEndpoint` based on the WebFlux foundation
* Extract `BaseHttpInboundEndpoint` for common
HTTP Inbound Channel Adapters options
* Make `spring-webmvc` and `spring-webflux` as `optional` dependencies
to let end-user to choose
* Refactor `HttpContextUtils` to include constants
for newly added WebFlux support
* Introduce `BaseHttpInboundEndpoint.setRequestPayloadTypeClass()`
for raw `Class<?>` and modify existing `setRequestPayloadType()`
for the `ResolvableType`
* Refactor existing MVC tests and XML components parsers to use
new `setRequestPayloadTypeClass()`
* Add `MessagingGatewaySupport.sendAndReceiveMessageReactive()` to get
a reply from downstream flow reactive back-pressure manner
* Add `IntegrationHandlerResultHandler` implementation to let WebFlux
infrastructure to handle the `Mono<Void>` from the `ReactiveHttpInboundEndpoint`
properly
* Fix `JdbcLockRegistryLeaderInitiatorTests` race condition to assert
the `initiator1` is elected eventually after yielding when the `initiator2`
is stopped

* Fix JavaDocs issue in the `HttpRequestHandlingMessagingGateway`
* Move all the "hard" logic in the `MessagingGatewaySupport#doSendAndReceiveMessageReactive`
to the `Mono` chain ensuring back-pressure when `sendAndReceiveMessageReactive()` is
called not from the Reactive Stream

Add test-case to demonstrate SSE

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

Some polishing and optimization for the
`MessagingGatewaySupport.doSendAndReceiveMessageReactive()`

More optimization for `MessagingGatewaySupport`

* Upgrade to Reactor 3.1 M3
* Document WebFlux-based components

Minor Doc Polishing
2017-07-20 12:19:17 -04:00
Gary Russell
6c62af53f4 INT-4309 Http Header Mapper VarArgs Instead of []
JIRA: https://jira.spring.io/browse/INT-4309

More convenient for Java Config.

*Upgrade to Reactor 3.1 B-S, Reactor-Netty 0.7 B-S and Security 5.0 B-S.
Otherwise we are not compatible with the latest SF
2017-07-05 13:38:20 -04:00
Artem Bilan
ecb7d03895 Upgrade to the latest SF and fix HTTP Reactive
https://build.spring.io/browse/INT-FATS5IC-206/

Also use `AopUtils.getTargetClass()` directly in the
`ReactiveHttpRequestExecutingMessageHandler` since it never returns `null`
2017-06-21 10:43:36 -04:00
Artem Bilan
6e38ed1dae Upgrade to Reactor 3.1.0.M2
https://build.spring.io/browse/INT-FATS5IC-197/
2017-06-12 11:56:27 -04:00
Artem Bilan
b7801f6311 Fix CookieTests for the latest SF
https://build.spring.io/browse/INT-MASTER-679/
2017-05-24 15:31:06 -04:00
Artem Bilan
ea89682368 INT-4252 IntegrationFlow: Allow Custom Bean Names
JIRA: https://jira.spring.io/browse/INT-4252

To allow to provide arbitrary bean names for the intermediate components
in the `IntegrationFlow` change `ComponentsRegistration` to return
a `Map<Object, String>` instead of raw `Collection<Object>`

* Use the value from that map in the `IntegrationFlowBeanPostProcessor` as a
fallback option before walking into bean name generation
* Provide `containerId` option for the AMQP DSL components

* Revert `@AfterClass` in the `AmqpTests`
* Expose `id()` for the `JmsDestinationAccessorSpec`
* Register `ListenerContainer` and `JmsTemplate`
as bean via `ComponentRegistration` in the particular JMS Java DSL components
* Fix `Jms` factory to populate the `JmsDefaultListenerContainerSpec`
for the `messageDrivenChannelAdapter()` without class specified

* Refactor AMQP DSL Inbound components to deal with the new ContainerSpec API
* Remove `containerId()` in favor of `id()` in the ContainerSpec
2017-05-23 14:46:06 -04:00
Artem Bilan
709cb7fe4c Remove Jackson Imports from JacksonJsonUtils
Since the classes load their imports explicitly we can't use them for
classes which provides utilities to check classpath

* Move imports to fully qualified names in the target utility method

**Cherry-pick to 4.3.x**

Move `JacksonJsonUtils.isPresent` methods to separate `JacksonPresent` class

Polishing
2017-05-11 15:39:47 -04:00
Artem Bilan
9543877c0c Fix FluxMessageChannel for Multi Sources
* Rename `ReactiveConsumer` to `ReactiveStreamsConsumer`
* Rename `FluxSubscribableChannel` to `ReactiveStreamsSubscribableChannel`
* Remove the `processor` functionality from the `FluxMessageChannel`
in favor of internal `FluxSink` as it is recommended by the Project Reactor:
> Most of the time, you should try to avoid using a Processor.
They are harder to use correctly and prone to some corner cases.

* Make connectable, upstream publishers for the `FluxMessageChannel` as
bridges to the internal `sink` via `this::send`.
This way we are able to receive data from multi sources.
When the source is completed (e.g. `Mono` in case of WebFlux response),
the downstream flow isn't completed.
* Rework `MessageChannelReactiveUtils#PollableChannelPublisherAdapter`
to be based on the `Flux.create()` and `onRequest()` to poll channel for messages
* Add one more request to the `ReactiveHttpRequestExecutingMessageHandler`
to be sure that we consume different `Mono`s by the `FluxSubscribableChannel`
properly without completion
* Upgrade to the `spring-io-plugin:0.0.7.RELEASE`

Add `IntegrationConsumer` implementation to the `ReactiveStreamsConsumer`
2017-05-10 14:02:35 -04:00
Gary Russell
168f372dd4 Make DefaultHttpHeaderMapper Easier to Subclass
It's difficult to subclass this mapper (e.g. to extend `toHeaders` to tweak the map)
because the factory methods for inbound and outbound mappers use private static fields
to set up the standard header mapping.

Extract that logic so that subclasses can create similar static methods and invoke the
setup code to set the standard header mapping.

Polishing: make more `DefaultHttpHeaderMapper` members available for inheritors
2017-05-04 17:27:26 -04:00
Gary Russell
572467b1c4 INT-4260: MessagePublishingErrorHandler Orig. Msg
JIRA: https://jira.spring.io/browse/INT-4260

MPEH: Populate the `ErrorMessage.originalMessage`,
if available and not the same as the `failedMessage`.

Polishing - rename exception to `MessagingExceptionWrapper`;
 make `MPEH` a subclass of `ErrorMessagePublisher`

PR Comments

Polishing - PR Comments
2017-05-03 16:32:49 -04:00
Gary Russell
ca231763a3 Rename ReactiveChannel
- as discussed last week

TODO:
- should we take the channel outside of the `AbstractMessageChannel` hierarchy?
  - avoid blocking interceptors
  - we would lose channel metrics though
- rename `ReactiveConsumer` ?

Polishing some missed renaming
2017-05-01 13:45:35 -04:00
Artem Bilan
a9aeff3ae1 Fix HTTP Reactive support according latest SF 2017-04-25 11:51:24 -04:00
Vedran Pavic
1dc3726e7d Make LockRegistry#obtain Java 8 based
This commit harmonizes `LockRegistry#obtain` logic in Zookeeper and JDBC
implementations with Redis implementation
by using Java 8 `ConcurrentMap#computeIfAbsent`

* Remove `synchronized (this.locks)` from the `expireUnusedOlderThan`
implementations because `iterator()` is thread-safe from `ConcurrentHashMap`
* Fix deprecation in the `IntegrationGraphControllerRegistrar`
* Revert Spring Security version to `4.2.2`, since `5.0 B-S` is broken
2017-04-21 20:00:34 -04:00
Gary Russell
da1b635d99 Fix Javadoc for HttpHeaderMapper 2017-04-14 18:42:23 -04:00
Artem Bilan
9e175054d0 Upgrade to the SF and SA BUILD-SNAPSHOTs
* Upgrade to Jackson-2.9.0 to align with SF
* Fix `ReactiveHttpRequestExecutingMessageHandler` to use latest `WebClient`
* Introduce `Supplier<URI> uriSupplier` to evaluate the `realUri` on demand.
In case of `WebClient` use `.uri(Function)` to perform `uriSupplier`
* Move `doNext()` for the `WebClientException` out of `one-way` block.
According the `RestTemplate` logic the erroneous response is handled
before returning from the `exchange()`.
Therefore both request/reply and one-way scenarios must have the same
error handling logic
* Some refactoring to the `AbstractHttpRequestExecutingMessageHandler`
and `AbstractHttpRequestExecutingMessageHandler` according a new `uriSupplier`
2017-04-08 08:46:13 -04:00
Artem Bilan
19c5402079 INT-4208: Add WebFlux-Based HttpMessageHandler
JIRA: https://jira.spring.io/browse/INT-4208

Since `AsyncRestTemplate` is deprecated in Spring 5.0, it doesn't make
sense to promote that feature via our new `AsyncHttpRequestExecutingMessageHandler`
component

* Rework (and rename) `AsyncHttpRequestExecutingMessageHandler` to
`ReactiveHttpRequestExecutingMessageHandler` and make it based on the
WebFlux `WebClient`
* Fix Java DSL (`ReactiveHttpMessageHandlerSpec`) and all tests according a new
logic in the `ReactiveHttpRequestExecutingMessageHandler`
* Fix XML namespace support to use new `ReactiveHttpRequestExecutingMessageHandler`
and don't expose unused options like `converters` and `request-factory`
* Fix `What's New` and `http.adoc`
* To remain with `async` mode for the `ReactiveHttpRequestExecutingMessageHandler`
behavior support fix `AbstractMessageProducingHandler` to adapt reply `Mono`
to the `SettableListenableFuture`
* Introduce new `reactive` behavior for the `AbstractMessageProducingHandler`
when `outputChannel` is `ReactiveSubscribableChannel` and perform
`.subscribeTo(Publisher)` for `Publisher` reply
* Upgrade to Spring AMQP `2.0 M3`
* Downgrade to Spring Security `4.2.2`

Address PR comments

Add async error handling to the one-way case

Minor polishing and checkstyle fix
2017-04-05 13:00:50 -04:00
Artem Bilan
75fe5d0f72 Fix HTTP out DSL for uri variables propagation
Since `AbstractHttpRequestExecutingMessageHandler` does a copy of
the provided `uriVariableExpressions`, we lose a coupling propagating
from the ctor.

* Move `uriVariableExpressions` propagation from the ctor to the
`getComponentsToRegister()`
2017-03-28 11:33:00 -04:00
Artem Bilan
d525edd90d Fix HTTP DSL inbound headers mapping delegation 2017-03-16 19:06:48 -04:00
Artem Bilan
9208fa52d6 INT-4242: Don't send body for HEAD and TRACE, too
JIRA: https://jira.spring.io/browse/INT-4242
Fixes spring-projects/spring-integration#2085

According to the RFC7231 (https://tools.ietf.org/html/rfc7231), the `HEAD` is fully similar to `GET` and its body does not have sense.
The `TRACE` method can't have body at all.
The `OPTIONS` may have body, but that is already custom target server logic to parse it properly

* Modify `AbstractHttpRequestExecutingMessageHandler` do not include `payload` as a request body for `GET`, `HEAD` and `TRACE`

Also see https://github.com/spring-projects/spring-integration/wiki/Spring-Integration-4.3-to-5.0-Migration-Guide
2017-03-08 16:27:17 -05:00
Gary Russell
37683f1b80 INT-4219: Test Polishing
JIRA: https://jira.spring.io/browse/INT-4219

- Use `AdditionalAnswers.returnFirstArgument` instead of lambda to return first arg
- Enable CheckStyle `AvoidStaticImport` for tests
- Fix static import violations in tests
2017-03-06 11:13:39 -05:00
Shiliang Li
802061985c INT-4208: Support AsycRest in HTTP Module
https://jira.spring.io/browse/INT-4208
https://jira.spring.io/browse/INT-4076

Add `AsyncRestTemplate` support in `HttpRequestExecutingMessageHandler` and corresponding config/dsl support

* Polishing Docs
2017-02-03 10:16:01 -05:00
Artem Bilan
2659baa821 Checkstyle ImportOrder for main and fixes 2017-01-23 12:58:36 -05:00