Skip to content

Conversation

artembilan
Copy link
Member

Fixes #2748

In many cases Spring Integration stack traces doesn't contain any
relations to end-user code.
Just because a target project code mostly contains only a configuration
for out-of-the-box components without any custom code.
When exception is thrown from such an out-of-the-box component, it is
hard from the stack trace to determine a configuration source for those
components.

  • Add a logic into the IntegrationObjectSupport to obtain a its own
    BeanDefinition from the BeanFactory to include a resource and
    source (if any) into the toString() representation, as well as add
    a new getBeanDescription() to get such an info at runtime
  • The toString() is simply used by this reference in the message
    for MessagingException thrown from the IntegrationObjectSupport
    implementations
  • Modify an exception message for the MessageTransformingHandler and
    MessageFilter to make it based on this.
    The AbstractMessageHandler already includes this into its exception
    message
  • Modify a AbstractConsumerEndpointParser and
    AbstractAmqpInboundAdapterParser (as a sample) to include a resource
    and source into a MessageHandler BeanDefinition.
  • Include an IntegrationFlow BeanDefinition resource
    (@Configuration class) and its bean method as a source into all
    child beans declared during flow parsing in the IntegrationFlowBeanPostProcessor
  • Add IntegrationFlowRegistrationBuilder.setSource() for manually
    registered flows: there is no configuration parsing phase to extract
    such an info from BeanFactory
  • Propagate that source into all the child beans provided by the
    IntegrationFlow
  • Modify a LambdaMessageProcessor exception message to include a
    method info in case of InvocationTargetException

Fixes spring-projects#2748

In many cases Spring Integration stack traces doesn't contain any
relations to end-user code.
Just because a target project code mostly contains only a configuration
for out-of-the-box components without any custom code.
When exception is thrown from such an out-of-the-box component, it is
hard from the stack trace to determine a configuration source for those
components.

* Add a logic into the `IntegrationObjectSupport` to obtain a its own
`BeanDefinition` from the `BeanFactory` to include a `resource` and
`source` (if any) into the `toString()` representation, as well as add
a new `getBeanDescription()` to get such an info at runtime
* The `toString()` is simply used by `this` reference in the message
for `MessagingException` thrown from the `IntegrationObjectSupport`
implementations
* Modify an exception message for the `MessageTransformingHandler` and
`MessageFilter` to make it based on `this`.
The `AbstractMessageHandler` already includes `this` into its exception
message
* Modify a `AbstractConsumerEndpointParser` and
`AbstractAmqpInboundAdapterParser` (as a sample) to include a `resource`
and `source` into a `MessageHandler` `BeanDefinition`.
* Include an `IntegrationFlow` `BeanDefinition` `resource`
(`@Configuration` class) and its bean method as a `source` into all
child beans declared during flow parsing in the `IntegrationFlowBeanPostProcessor`
* Add `IntegrationFlowRegistrationBuilder.setSource()` for manually
registered flows: there is no configuration parsing phase to extract
such an info from `BeanFactory`
* Propagate that `source` into all the child beans provided by the
`IntegrationFlow`
* Modify a `LambdaMessageProcessor` exception message to include a
method info in case of `InvocationTargetException`
@artembilan
Copy link
Member Author

I would say we can merge it with what we have so far.
Everything else can be addressed later or on demand.
Although I agree that some What's New should be added any way...

`IntegrationObjectSupport` to avoid tests modifications for mocking
directly into `ConfigurableListableBeanFactory`.
Use `instanceof` instead in the `getBeanDescription()`
@garyrussell
Copy link
Contributor

Quite a lot of test failures (travis)

@artembilan
Copy link
Member Author

Yep! Fighting with that...

Copy link
Contributor

@garyrussell garyrussell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM; just one minor question/issue.

public void sendTimeoutDefault() {
@Test
// INT-1154
void sendTimeoutDefault() {
Copy link
Contributor

@garyrussell garyrussell Jul 12, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?? Why the newlines on all of these?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like fresh IDEA code formatting...
Thanks for heads up. I will remove it altogether.

to rely on the `NamedComponent` for channel names instead of
always call `toString()` which is now much more than just a bean name
* Don't describe a `componentName` if it is the same as a `beanName`
* Check for parent `BeanDefinition` in the `IntegrationFlowBeanPostProcessor`
before calling its meta-info
* Fix tests according new `IntegrationObjectSupport.toString()` behavior
@garyrussell garyrussell merged commit c712416 into spring-projects:master Jul 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DSL components not easily recognizable in stack trace
2 participants