Commit Graph

2293 Commits

Author SHA1 Message Date
Artem Bilan
71fd60fda6 Add default expressions for ExpEvalReqHAdvice (#2738)
* Add default expressions for ExpEvalReqHAdvice

https://stackoverflow.com/questions/54546728/how-to-handle-ftpoutboundadapter-connection-exception-in-spring-integration-flow

When channels are configured for the `ExpressionEvaluatingRequestHandlerAdvice`,
but no expressions, the logic is not performed.
In other words: we can evaluate expressions, when no channels,
but we  don't send messages to channels when no expressions.

* Provide default expressions to be evaluated to `payload`, when only
channels are provided.

* * Remove asserts for expression setters
2019-02-06 16:21:03 -05:00
Gary Russell
d56e29b28d GH-2733: Polishing
- fix `equals()` implementation issues.
2019-02-06 09:00:22 -05:00
Gary Russell
f6c8a652eb GH-2733: Fix Meter Memory Leak
Fixes https://github.com/spring-projects/spring-integration/issues/2733

`AbstractMessageChannel` exception meters caused a memory leak because they
are stored in a `Set` for destruction purposes but did not implement
`hashCode` and `equals`.

Add `hashCode()` and `equals()` to all meter facades, delegating to the
underlying Micrometer objects.
2019-02-05 09:48:47 -05:00
Gary Russell
65b889925a Revert INT-4386: Support Instant in schedule expr.
This reverts commit f901c4e167.
2019-01-31 16:23:59 -05:00
Artem Bilan
f901c4e167 INT-4386: Support Instant in schedule expressions
JIRA: https://jira.spring.io/browse/INT-4386

* Expose `java.time` in the `IntegrationEvaluationContextFactoryBean`
ot simply a `T()` SpEL operator
* Add `Instant` result evaluation to the `delayExpression`
2019-01-31 16:13:27 -05:00
Artem Bilan
020ea76d59 Make IOS.setTaskScheduler() as public (#2725)
* Make IOS.setTaskScheduler() as public

* Make `IntegrationObjectSupport.setTaskScheduler()` as `public` and
remove all the overrides for visibility
* Fix Sonar smells for all the affected classes

* * Fix `throws Exception` for affected classes to avoid compilation errors

* * Fix "merely rethrow" smell
* Revert `throws Exception` for `AbstractEndpoint.destroy()`

* * Catch a couple exceptions from `destroy()`
2019-01-30 13:59:37 -05:00
Artem Bilan
9ab6779dc2 Fix new Sonar smell and some other in JMX module (#2716)
* Fix new Sonar smell and some other in JMX module

* * Fix issues after testing
2019-01-24 11:55:46 -05:00
Gary Russell
bac3565dfd GH-2714: Fix PollSkipAdvice
Fixes https://github.com/spring-projects/spring-integration/issues/2714

Return null instead of false when poll skipped.
2019-01-24 10:46:04 -05:00
Gary Russell
fff968e5ad Add Duration overloads to Pollers factory
- test adds coverage to all time-based factory methods
2019-01-23 17:39:12 -05:00
Artem Bilan
690a2c3c3e Implement Lifecycle for IntegrationComponentSpec
Since an `IntegrationComponentSpec` is a `FactoryBean`, all it's target
callbacks and lifecycle is controlled over a `FactoryBean`.

* Add `SmartLifecycle` for the `IntegrationComponentSpec` to delegate
lifecycle hooks to the `target` if necessary
* Refactor `IntegrationComponentSpec` to be an `AbstractFactoryBean`
which is a central place for the `FactoryBean`, `InitializingBean` and
`DisposableBean` interfaces

**Cherry-pick to 5.0.x**
2019-01-23 10:08:06 -05:00
Artem Bilan
d37e6562d8 Fix DSL to deal with beanNames for handlers (#2707)
* Fix DSL to deal with beanNames for handlers

When consumer endpoint is created by the Framework, the target
`MessageHandler` gets a `componentName` from the `ConsumerEndpointFactoryBean`.
Therefore we can't rely on the `getComponentName()` when we create beans
from Java DSL.

* Introduce `NamedComponent.getBeanName()` contract; make it default
to the `getComponentName()`; implement this method from the
`IntegrationObjectSupport`
* Use this new `getBeanName()` from the `IntegrationFlowBeanPostProcessor`
and `StandardIntegrationFlowContext` for better existing beans checks
and possible reuse existing `MessageHandler` in different endpoints
* Optimize `FixedSubscriberChannel` and implement `getBeanName()` over there
* Implement `getBeanName()` in the `AbstractMessageSource`; use
`ExpressionEvalMap` to evaluate headers expressions
* Implement `getBeanName()` in `Trackable*Metrics` classes as delegation
to the `this.trackable`

* * Fix race condition around `discardChannelName` property in the `MessageFilter`
2019-01-22 11:04:47 -05:00
Artem Bilan
0ac766040f Fix a couple new Sonar smells 2019-01-18 15:27:45 -05:00
Artem Bilan
462dc98803 GH-2695: Add proxy option to @EnablePublisher (#2701)
* GH-2695: Add proxy option to @EnablePublisher

Fixes spring-projects/spring-integration#2695

To configure a `proxyTargetClass=true` we need declare a
`PublisherAnnotationBeanPostProcessor` bean manually, but that may cause
a confuse when `@EnablePublisher` is still present.
So, target service is proxied twice

* Expose `proxyTargetClass` and `order` into the `@EnablePublisher`
and `<enable-publisher>`
* Refactor `PublisherAnnotationBeanPostProcessor` to extend an
`AbstractBeanFactoryAwareAdvisingPostProcessor` to avoid AOP boilerplate
code altogether
* Add assertion into the `PublisherAnnotationBeanPostProcessor` to be
sure that only one of its instance is present in the application context

* * Polishing error message and Docs
2019-01-17 10:44:39 -05:00
Cameron Mayfield
cd8cbaa99c GH-2699: Make expressions cache concurrent
Fixes spring-projects/spring-integration#2699

* [GH-2699] Match style

* [GH-2699] Shorten test line length

**Cherry-pick to 5.0.x**
2019-01-16 18:03:03 -05:00
Artem Bilan
eed16f02ca Fix BeanFactory propagation for MMInvokerHelper (#2694)
* Fix BeanFactory propagation for MMInvokerHelper

* Remove check for `null` in the
`MessagingMethodInvokerHelper.isProvidedMessageHandlerFactoryBean()`
* Fix `RecipientListRouter` for `BeanFactory` propagation to the
`Recipient.selector`
* Fix tests for `BeanFactory` population and propagation
* Add `errorChannel` into the `TestUtils.createTestApplicationContext()`
* Fix some Sonar smell, including new reported

* * Restore NPE check for the `BeanFactory` in the
`MessagingMethodInvokerHelper` to avoid breaking changes in the current
point release
* Some other polishing and optimizations in the
`MessagingMethodInvokerHelper`
2019-01-15 15:16:33 -05:00
Artem Bilan
d4a03006cf Fix ambiguity for NullChannel instances bean name
When we use explicitly `new NullChannel()` in DSL definition, we don't
provide a bean name and just end up with an explicit `nullChannel`
component name in the class.
This way it clashes with the global `errorChannel`, but since instances
are different we get a `BeanDefinitionOverrideException`

* Remove explicit `nullChannel` component name in the `NullChannel` in
favor of the generated name as it is done for any regular beans
* Some internal polishing in the `NullChannel`
* Some polishing in the `IntegrationFlowBeanPostProcessor` to deal with
`NullChannel` as with any other regular `AbstractMessageChannel`s and
generate a proper name for it within the scope of the current
`IntegrationFlow`
2019-01-10 15:21:56 -05:00
Oleg Zhurakousky
0d1312874c INT-4571 Make MessageHandlerMethodFactory injectable
Make MessageHandlerMethodFactory injectable into MessagingMethodInvokerHelper
Allow 'handlerMethod' to be overridden
Deprecate HandlerMethodArgumentResolversHolder
Add 'integrationMessageHandlerMethodFactory' property to IntegrationContextUtils
Add test that actually validates that custom resolver gets picked up

* Polishing code style and some code smells
2019-01-10 13:44:19 -05:00
Gary Russell
2766707547 Sonar fixes
- remaining hidden fields

* Fix copyright
2019-01-09 13:30:08 -05:00
Gary Russell
e40cfe101e Sonar fixes
Hidden fields, `o.s.i.a*` through `o.s.i.j*`.
2019-01-09 10:02:19 -05:00
Artem Bilan
6eeec50b4a INT-4572: Add MessageProducer.setOutputChannelName
JIRA: https://jira.spring.io/browse/INT-4572

* Add `setOutputChannelName()` contract into the `MessageProducer`
to avoid proxy unwrapping and casting to the `MessageProducerSupport`
2019-01-08 16:32:10 -05:00
Gary Russell
1bafe89d49 Sonar Fixes
- avoid parameter assignments
2019-01-07 11:35:58 -05:00
Gary Russell
e8df546b04 Sonar Fixes - Javadoc-only imports 2019-01-02 12:26:22 -05:00
Artem Bilan
a39881fd0d Fix new issues in Sonar
* Use properly `IntegrationObjectSupport.extractTypeIfPossible()`
2018-12-23 11:48:33 -05:00
Gary Russell
113a371f2c Remove Exception from IOS.onInit() 2018-12-22 17:25:56 -05:00
Artem Bilan
81b4ea1bef Sonar fixes according latest report (#2676)
* Sonar fixes according latest report

* Fix initialization order in the `GatewayMethodInboundMessageMapper`

* Fix mock in the `DelegatingSessionFactoryTests`

* Fix `AbstractRemoteFileOutboundGateway.listFilesInRemoteDir`

* * PR comments

* * Fix `AbstractRemoteFileOutboundGateway.listFilesInRemoteDir` complexity
2018-12-22 11:57:35 -05:00
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
a01d09f0f1 Sonar Fixes
Final critical smells.
2018-12-20 11:58:32 -05:00
Gary Russell
7790f9e550 Sonar fixes
Critical issues `o.s.i.t*`, `o.s.i.u*`.

* Polishing - PR Comments.
2018-12-19 14:49:27 -05:00
Artem Bilan
8ce8bf9d73 Fix code smell in websocket and webflux modules (#2669)
* * Fix code smell in websocket and webflux modules

* * More fixes

* * Fix NPE in the `IntegrationHandlerResultHandler`
2018-12-19 12:33:47 -05:00
Gary Russell
e8bd31cc37 Sonar fixes
Critical smells `0.s.i.r*`

* Polishing - PR Comments.
2018-12-19 09:47:57 -05:00
Artem Bilan
12dd73d219 Fix code smell for PayloadTypeConvertTransformers 2018-12-18 15:27:34 -05:00
Artem Bilan
3dd8b63576 INT-4569: Disallow beans override in DSL (#2664)
* INT-4569: Disallow beans override in DSL

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

* Thorw `BeanDefinitionOverrideException` from the
`IntegrationFlowBeanPostProcessor` when it detects existing bean and it
is not the same object we try to register from the DSL
* Document limitations about `prototype` beans
* Some polishing in the DSL chapter of the docs

* * Fix algorithm in the `IntegrationFlowBeanPostProcessor.noBeanPresentForComponent()`

* * Polishing dsl.adoc
* Call `BeanFactory.initializeBean()` for existing beans if they are
`prototype`

* * Code formatting in the `ManualFlowTests`
2018-12-18 14:22:17 -05:00
Gary Russell
65df35bfd1 Sonar fixes
Critical smells `o.s.i.m*`.
2018-12-18 13:28:59 -05:00
Gary Russell
7efe79f457 Sonar fixes
Critical issues for `o.s.i.j*` (except `jdbc`).
2018-12-14 16:12:04 -05:00
Gary Russell
3f522f7efe Fix "new" Sonar issues
Reported as new due to touched source file.
2018-12-13 23:21:42 -05:00
Artem Bilan
d7356aa85d Use Context CL wherever it is applicable (#2656)
* Use Context CL wherever it is applicable

* Use `ClassUtils.getDefaultClassLoader()` in the `IntegrationManagementConfigurer`
for checking a Micrometer presence from the `afterSingletonsInstantiated()`
* Use `ClassUtils.getDefaultClassLoader()` in the `ScatterGatherHandler`
to load required class
* Refactor `HeaderEnricherParserSupport` do not use CL at all.
The `TypedStringValue` will resolve a target type later by the
`BeanFactory`.
This way we honor a property placeholder behavior for the `type` XML
attribute

* * Use `ClassUtils.getDefaultClassLoader()` in the ScatterGatherHandler ctor
2018-12-13 16:14:37 -05:00
Gary Russell
563f526ddc Sonar Fixes
Critical smells for packages `o.s.i.i*`.

* Polishing

* Polishing

* Missed saving a file.

* Polishing - PR Comments

* More PR comments.
2018-12-07 14:59:27 -05:00
Gary Russell
4760c54097 Sonar Fixes
Critical smells `o.s.i.h*`.
2018-12-07 12:39:19 -05:00
Artem Bilan
536b6b1786 INT-4565: Fix IntComponentScan for profiles (#2652)
* INT-4565: Fix IntComponentScan for profiles

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

* Propagate an `Environment` to the internal `ClassPathScanningCandidateComponentProvider`
in the `IntegrationComponentScanRegistrar` for proper profiles activation
* Ensure the logic works in the `GatewayInterfaceTests`
* Some polishing and performance improvement for the `GatewayInterfaceTests`
* Add a note about `@Profile` in the `gateway.adoc`
* Polishing for the `gateway.adoc`

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

* * Add not activated by profile gateway interface into the `GatewayInterfaceTests`
* More `GatewayInterfaceTests` polishing
* Fix typo in the `gateway.adoc`

* Fix Checkstyle violation
2018-12-06 15:41:40 -05:00
Gary Russell
2cde493fbf Sonar Fixes
Packages `o.s.i.g*`

* Polishing - PR comments
2018-12-06 15:23:54 -05:00
Gary Russell
9832f61d2a INT-4564: ACMH: Fix erroneous error log
JIRA: https://jira.spring.io/browse/INT-4564

INT-4550 added an error log when multiple ACMHs were registered with the
same store; the error log logic was incorrect and the error was logged
when the first ACMH was registered.
2018-12-04 15:13:49 -05:00
Gary Russell
62fc7df693 Sonar Fixes
Critical smells, packages `o.s.i.a*` to `f*`.

Plus new smells caused by these changes.
2018-12-03 10:44:26 -05:00
Gary Russell
7135d0603c INT-4553: Store-backed QueueChannel improvements
JIRA: https://jira.spring.io/browse/INT-4553
Fixes https://github.com/spring-projects/spring-integration/issues/2628
Fixes https://github.com/spring-projects/spring-integration/issues/2629

- Avoid `size()` calls on the MGS, use `poll()` instead.
- Optimize the indexes for the `INT_CHANNEL_MESSAGE` table.

Avoid size call when no timeout too.

Polishing - PR Comments

Missed a doc fix

Another missed %PREFIX%

Fix underscores

Polishing; PR comments; make MGQ extendable.

Fix version in doc.

* Polishing `@since`
* Use diamonds whenever it is possible

**Cherry-pick to 5.0.x**
2018-11-30 13:07:59 -05:00
Gary Russell
f6e9e6649a Fix Resequencer test wait time
https://build.spring.io/browse/INT-MASTERSPRING40-534/

Since we are expecting a message, a large wait time is no detriment
to test runtime and provides a more reliable test on a busy CI server.
2018-11-24 11:11:35 -05:00
Gary Russell
c3f8c4af27 More Sonar resolutions 2018-11-20 14:15:59 -05:00
Gary Russell
aa8068a71b Sonar Address new issues in LambdaMessageProcessor 2018-11-20 11:27:18 -05:00
Gary Russell
c9ae6c794f Sonar: AMQP Fixes
- critical smells
- also import in IMHA

* Polishing
2018-11-20 09:38:15 -05:00
Gary Russell
0c33591676 Log error for class cast exception on lambda
**cherry-pick to 5.0.x**

* Fix test

* Polish log message.

* Polishing - docs and javadocs.
2018-11-19 16:56:35 -05:00
Artem Bilan
b3cf864675 Fix LambdaMessageProcessor for conversion
SO: https://stackoverflow.com/questions/53378821

There is no need to jump into the `MessageConverter` if payload type
is assignable to the target type
2018-11-19 13:39:36 -05:00
Artem Bilan
e9c554534a INT-4556: Fix messaging anns for FactoryBeans
JIRA: https://jira.spring.io/browse/INT-4556

We definitely need to resolve a `@Bean` method to the target object to
be sure do not create a new `MessageHandler` bean.

**Cherry-pick to 5.0.x**
2018-11-19 13:01:52 -05:00