question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

RequestHandlerProvider evaluated too early for Spring-Integration

See original GitHub issue

Version 3.0.0-SNAPSHOT

Issue Kind: Bug Report (possibly)

Following https://github.com/springfox/springfox/issues/550 I have started to implement support for spring-integration in spring-boot 2.

I have tried to follow the approach taken by the WebFlux support by adding a RequestHandlerProvider plugin which uses the IntegrationRequestMappingHandlerMapping internally.

The Springfox DocumentationPluginsBootstrapper evaluates my RequestHandlerProvider, but at that point, the mappingRegistry of the IntegrationRequestMappingHandlerMapping is still empty. The reason is that the IntegrationRequestMappingHandlerMapping purposefully postpones the call to detectHandlerMethods, it happens not in afterPropertiesSet, but on ContextRefreshedEvent. This code is from IntegrationRequestMappingHandlerMapping:

@Override
public void afterPropertiesSet() {
	// No-op in favor of onApplicationEvent
}

/**
 * {@link HttpRequestHandlingEndpointSupport}s may depend on auto-created
 * {@code requestChannel}s, so MVC Handlers detection should be postponed
 * as late as possible.
 * @see RequestMappingHandlerMapping#afterPropertiesSet()
 */
@Override
public void onApplicationEvent(ContextRefreshedEvent event) {
	if (!this.initialized.getAndSet(true)) {
		super.afterPropertiesSet();
	}
}

It seems that DocumentationPluginsBootstrapper wrongly assumes it can rely on all RequestHandlerProviders to be initialized when it collects the request handlers. It returns Integer.MAX_VALUE in getPhase to ensure this, but apparently that is not enough.

One possibility might be to change DocumentationPluginsBootstrapper so that it initializes last on ContextRefreshedEvent (with very low precedence) or something else which is more appropriate.

What do you think?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
dschultencommented, Nov 23, 2018
0reactions
dschultencommented, Nov 7, 2018

The usual swagger annotations are a challenge, since there is no code to annotate in SI. I am considering to use spring-restdoc or a similar approach: mvc or webclient tests document inputs and outputs as documentation snippets. They generate adoc snippets. Is there a plugin to include external documentation fragments already?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Stack Overflow
Spring-integration ExpressionEvaluatingRequestHandlerAdvice unable to evaluate the failureExpression · Ask Question. Asked 1 year, 10 months ago.
Read more >
Spring Integration
Spring Integration's primary goal is to provide a simple model for building enterprise integration solutions while maintaining the separation of concerns that ...
Read more >
Optimizing Spring Integration Tests - Baeldung
In this article, we'll have a holistic discussion about integration tests using Spring and how to optimize them. First, we'll briefly ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found