Hi, this is a first-timers-only issue. This means we've worked to make it more legible to folks who either haven't contributed to our codebase before, or even folks who haven't contributed to open source before.

If that's you, we're interested in helping you take the first step and can answer questions and help you out as you do. Note that we're especially interested in contributions from people from groups underrepresented in free and open source software!

If you have contributed before, consider leaving this one for someone new, and looking through our general ideal-for-contribution issues. Thanks!

Background

Spring Boot provides a number of callback interfaces that can be used to customize the beans that it auto-configures. For example, a TomcatConnectorCustomizer can be used to customize a Tomcat Connector.

Problem

At the moment, the only way to add customizations to a RSocketMessageHandler is to provide your own RSocketMessageHandler bean which completely overrides the auto-configured RSocketMessageHandler bean. This can be bit tedious and we should allow providing customizers instead which can be applied to the bean created by Spring Boot.

It would look something like:

@Bean
public RSocketMessageHandlerCustomizer messageHandlerCustomizer() {
    return (handler) -> handler.setRouteMatcher(...);
}

Solution

Add a RSocketMessageHandlerCustomizer type. Beans of RSocketMessageHandlerCustomizer type should be applied automatically to RSocketMessageHandler, this can be done here.

The ObjectProvider interface can be used for injecting a dependency. Here is an example that can be used to inject customizers when there can be 0..n of them.

Tests are here.

Steps to Fix

  • [x] Claim this issue with a comment below and ask any clarifying questions you need
  • [x] Set up a repository locally following the Contributing Guidelines
  • [x] Try to fix the issue following the steps above
  • [x] Commit your changes and start a pull request.

Comment From: joshlong

This is following up on https://github.com/spring-projects/spring-boot/issues/18356#issuecomment-587316687

Comment From: aartiguptaa

I can pick this up !

Comment From: snicoll

@aartiguptaa thank you very much, it's all yours. Let us know if you have any question.

Comment From: cicioflaviu

If something comes up and @aartiguptaa will not be able to complete the task, I'm available to take over.

Comment From: mbhave

@aartiguptaa how's it going? Please let us know if you need any help tackling this issue.

Comment From: logicatmidod

Hi

looks like this one's gone. please let me know if there is any first timer issue which I can contribute to?

Thanks

Comment From: snicoll

@logicatmidod we can't let you know when there are a first timer issue available. If you're trying to contribute, I've answered a similar question this morning, please read this comment. We prefer no to use the issue tracker for questions so for any follow-up questions on the project, please join the community on Gitter.

Comment From: aartiguptaa

Apologies for the delay folks, I am working on this now, and should have more updates this weekend.

Comment From: corneliouzbett

@joshlong @snicoll could you refer me to a good first-time issue to work on. I want to understand the codebase and contribute more In future

Comment From: snicoll

@aartiguptaa How are things? Do you need help with anything?

@corneliouzbett I've answered that question already here but it was hidden so I just changed that.

Comment From: aartiguptaa

@snicoll , @mbhave , which dependency should the Object Provider interface be used to inject?

Comment From: snicoll

I am not sure I got the question. ObjectProvider is part of Spring Framework. There is an example here

Comment From: aartiguptaa

The instructions say "The ObjectProvider interface can be used for injecting a dependency. Here is an example that can be used to inject customizers when there can be 0..n of them."

which dependency should ObjectProvider inject ?

Is it the message handler bean ? or a customizer bean?

@Bean
@ConditionalOnMissingBean(RSocketMessageHandler.class)
public <WhatType?>  RSocketMessageHandler(ObjectProvider<RSocketMessageHandlerCustomizer> customizers) {
        (what should this inject?)
}

Comment From: scottfrederick

@aartiguptaa The existing method that looks like this:

    @Bean
    @ConditionalOnMissingBean
    public RSocketMessageHandler messageHandler(RSocketStrategies rSocketStrategies) {
        RSocketMessageHandler messageHandler = new RSocketMessageHandler();
        messageHandler.setRSocketStrategies(rSocketStrategies);
        return messageHandler;
    }

would be changed to take the new optional customizer dependency using ObjectProvider, looking something like this:

    public RSocketMessageHandler messageHandler(RSocketStrategies rSocketStrategies, ObjectProvider<RSocketMessageHandlerCustomizer> customizers) {
            ...
    }

Inside of that method, each RSocketMessageHandlerCustomizer can be applied to the messageHandler object as in this example.

Comment From: aartiguptaa

Trying to push a PR, on a new branch, do I need special permissions to add a new branch? git push --set-upstream origin RSocketMessageHandlerCustomizer Username for 'https://github.com': aartiguptaa Password for 'https://aartiguptaa@github.com': remote: Permission to spring-projects/spring-boot.git denied to aartiguptaa. fatal: unable to access 'https://github.com/spring-projects/spring-boot.git/': The requested URL returned error: 403

Comment From: scottfrederick

@aartiguptaa You'll need to create your own fork of the spring-boot repository and push your changes there.

After creating a fork, you should be able to

$ git remote origin set-url https://github.com/aartiguptaa/spring-boot

to point the origin remote to your fork instead of spring-projects/spring-boot. Then you can

$ git push --set-upstream origin RSocketMessageHandlerCustomizer

to push your new branch to your own fork.

Once the branch is pushed to your fork, see the github docs for creating a pull request.

Comment From: wilkinsona

Closing in favour of #21081.