Skip to content

Conversation

Raheela1024
Copy link
Contributor

No description provided.

Copy link
Member

@wilkinsona wilkinsona left a comment

Choose a reason for hiding this comment

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

Thanks very much for opening your first Spring Boot pull request. I've left a few review comments. Could you please take a look and make the necessary changes? Feel free to ask any questions you have if anything isn't clear or you need some more guidance. Thanks again.


@Bean
public TomcatConnectorCustomizer connectorCustomizer() {
return (connector) -> connector.setPort(9001);
Copy link
Member

Choose a reason for hiding this comment

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

This might cause a port clash if something else is used port 9001. It would be safer if the customizer didn't do anything to the connector.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

runner.run((context) -> {
TomcatServletWebServerFactory factory = context
.getBean(TomcatServletWebServerFactory.class);
assertThat(factory.getTomcatContextCustomizers()).hasSize(1);
Copy link
Member

Choose a reason for hiding this comment

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

If this test passes then this assertion isn't quite right as TomcatContextCustomizerConfiguration doesn't define a TomcatContextCustomizer. The assertions needs to be written such that if you remove .withUserConfiguration(TomcatContextCustomizerConfiguration.class) the test will fail.

Copy link
Contributor Author

@Raheela1024 Raheela1024 Dec 19, 2018

Choose a reason for hiding this comment

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

assertThat(factory.getTomcatContextCustomizers()).hasSize(1); is working fine in TomcatServletWebServerFactory case. If i remove .withUserConfiguration(TomcatContextCustomizerConfiguration.class) from test assertion going to fail. If we doesn't define TomcatContextCustomizer into TomcatContextCustomizerConfiguration assertion is also failed because tomcatContextCustomizers into TomcatReactiveWebServerFactory list is zero.


@Bean
public TomcatConnectorCustomizer connectorCustomizer() {
return (connector) -> connector.setPort(9001);
Copy link
Member

Choose a reason for hiding this comment

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

This might cause a port clash if something else is used port 9001. It would be safer if the customizer didn't do anything to the connector.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

runner.run((context) -> {
TomcatServletWebServerFactory factory = context
.getBean(TomcatServletWebServerFactory.class);
assertThat(factory.getTomcatContextCustomizers()).hasSize(1);
Copy link
Member

Choose a reason for hiding this comment

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

If this test passes then this assertion isn't quite right as TomcatContextCustomizerConfiguration doesn't define a TomcatContextCustomizer. The assertions needs to be written such that if you remove .withUserConfiguration(TomcatContextCustomizerConfiguration.class) the test will fail.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

TomcatServletWebServerFactory already have one TomcatContextCustomizer into tomcatConnectorCustomizers list. if i remove .withUserConfiguration(TomcatContextCustomizerConfiguration.class) assertion is not failed.

We have an option that add assert for size 2 because one is already there and other is added by our configuration class. If i am thinking wrong you can guide me towards correcting the assertion.

@wilkinsona wilkinsona added the type: enhancement A general enhancement label Dec 19, 2018
@wilkinsona wilkinsona changed the title Fixes gh-15062 Apply TomcatConnectorCustomizer and TomcatContextCustomizer beans automatically Dec 19, 2018
@wilkinsona wilkinsona removed the status: waiting-for-triage An issue we've not yet triaged label Dec 19, 2018
@wilkinsona wilkinsona added this to the 2.2.x milestone Dec 19, 2018
wilkinsona added a commit that referenced this pull request Dec 19, 2018
* gh-15492:
  Polish "Apply context and connector customizer beans to Tomcat factories"
  Apply context and connector customizer beans to Tomcat factories
@wilkinsona
Copy link
Member

wilkinsona commented Dec 19, 2018

@Raheela1024 Thank you very much for making your first contribution to Spring Boot. I have merged the proposed changes into the master branch along with a tiny bit of polish to change the names of a couple of @Bean methods in the tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants