Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Spring Boot 3 integration modules #4574

Merged
merged 25 commits into from
Mar 28, 2023
Merged

Add Spring Boot 3 integration modules #4574

merged 25 commits into from
Mar 28, 2023

Conversation

ikhoon
Copy link
Contributor

@ikhoon ikhoon commented Dec 14, 2022

Motivation:

Spring 6 and Spring Boot 3 have been released.
https://spring.io/blog/2022/11/24/spring-boot-3-0-goes-ga

Modifications:

  • New modules are added:
    • spring-boot3-{autoconfigure,starter}
    • spring-boot3-actuator-{autoconfigure,starter}
    • spring-boot3-webflux-{autoconfigure,starter}
    • tomcat10
  • Use Java 17 for Spring Boot 3 module, Spring examples and integration tests.
  • Use Java 11 for Tomcat 10 module.
  • Migrate removed or changed API

Dependencies:

  • Add Spring Boot 3.0.2
  • Add hibernate-validator 8.0.0
  • Bump Micrometer into 1.10.2
  • Add Jakarta dependencies
    • jakarta-inject 2.0.1
    • jakarta-validation 3.0.2
    • jakarta-websocket 2.1.0

Result:

You can now use Spring Boot 3 with Armeria.

Motivation:

Spring 6 and Spring Boot 3 have been released.
https://spring.io/blog/2022/11/24/spring-boot-3-0-goes-ga

Note that the added modules will not be published until we refactor
`spring-boot2-autoconfigure` internals.

Modifications:

- Add Spring Boot 3 integrations symmetirically with Spring Boot 2.
  - `publish` flags are not added intentionally.
- Set the release target for Spring Boot 3 and examples to Java 17.
- Add `PortUtil` and migrate off `SocketUtils`.
- Migrate AutoConfiguration in spring.factories to
  `o.s.b.a.AutoConfiguration.imports`.
  https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.7-Release-Notes#new-autoconfiguration-annotation
- Change `management.metrics.export.defaults.enabled` to
  `management.promethus.metrics.export.enabled` in tests
  spring-projects/spring-boot#30381
- Fix compile errors in the webflux integration
- Migrate moved `LocalServerPort` and `LocalManagementPort`.

Depedencies:

- Add Spring Boot 3.0.0
- Add `hibernate-validator 8.0.0
- Bump Micrometer into 1.10.2
- Add Jakarta dependencies
  - jakarta-inject 2.0.1
  - jakarta-validation 3.0.2
  - jakarta-websocket 2.1.0

Result:

Experimentally set up Spring Boot 3 integrations.
@ikhoon ikhoon modified the milestones: 1.21.0, 1.22.0 Dec 15, 2022
@ikhoon ikhoon marked this pull request as draft December 15, 2022 12:41
@ikhoon ikhoon marked this pull request as ready for review January 25, 2023 12:19
@ikhoon ikhoon modified the milestones: 1.22.0, 1.23.0 Feb 6, 2023
@ikhoon
Copy link
Contributor Author

ikhoon commented Feb 6, 2023

Rescheduled the milestone to 1.23.0

@cj848
Copy link

cj848 commented Feb 15, 2023

When can this PR be merged? This is a very much awaited PR.

Copy link
Member

@minwoox minwoox left a comment

Choose a reason for hiding this comment

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

Excellent work! 👍 👍 👍
Left nits and questions.

gradle/scripts/lib/java.gradle Show resolved Hide resolved
api libs.jakarta.inject
compileOnly libs.jakarta.validation
// We may remove jakarta.websocket dependencies if Armeria webflux module supports WebSocket.
implementation libs.jakarta.websocket
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure if we need this or not. Shouldn't the user who wants to use WebSocket include this dependency?

Copy link
Contributor Author

@ikhoon ikhoon Mar 9, 2023

Choose a reason for hiding this comment

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

https://github.com/spring-projects/spring-framework/blob/main/spring-webflux/src/main/java/org/springframework/web/reactive/socket/server/support/HandshakeWebSocketService.java#L272-L291
WebFlux in Spring Boot 3 uses Jakarta Websocket as a fallback if no custom WebSocket RequestUpgradeStrategy is detected. The explanation was not enough. Let me update the comment.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks a lot for the explanation. 🙇

@minwoox
Copy link
Member

minwoox commented Feb 16, 2023

When can this PR be merged? This is a very much awaited PR.

Sorry about the delay. 😓
I think this is almost done and I hope we could include this in the next release. Please stay tuned. 🙇

Copy link
Contributor

@jrhee17 jrhee17 left a comment

Choose a reason for hiding this comment

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

Left only nits and questions 😄 Thanks for the handling this issue @ikhoon 🙇

gradle.properties Outdated Show resolved Hide resolved
gradle/scripts/lib/java.gradle Outdated Show resolved Hide resolved
gradle/scripts/lib/java.gradle Outdated Show resolved Hide resolved
gradle/scripts/lib/java.gradle Show resolved Hide resolved
spring/boot2-autoconfigure/build.gradle Outdated Show resolved Hide resolved
@@ -4,6 +4,11 @@ management:
prometheus:
enabled: true # In order to inject PrometheusMeterRegistry

prometheus:
Copy link
Contributor

Choose a reason for hiding this comment

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

I understood that

  • spring-boot 1,2: management.metrics.export.prometheus.enabled
  • spring-boot 3: prometheus.metrics.export.enabled

Which is why both are added. Am I understanding correctly?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I put both properties to share this configuration file. We can check out the change properties in
https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-3.0.0-Configuration-Changelog

- management.metrics.export.prometheus.enabled
+ management.prometheus.metrics.export.enabled

// called. It can lead to
// leaking of the buffer when an
// HttpResponse is canceled.
return writeWithInternal(Mono.just(buffer).doOnSubscribe(s -> subscribed.set(true))
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you have plans to file an issue/fix upstream also? If I understand correctly this also affects upstream. Having it fixed there would simplify code from our side a lot.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If I understand correctly this also affects upstream.

It might be a problem only on our side. If we didn't recover the CancelledSubscriptionException exception,
https://github.com/line/armeria/blob/master/spring/boot3-webflux-autoconfigure/src/main/java/com/linecorp/armeria/spring/web/reactive/ArmeriaServerHttpResponse.java#L93-L95
the buffer would be released by

Anyway, it would be worth discussing it with upstream maintainers. Let me create an issue for it.

}

tasks.compileJava.dependsOn(generateSources)

Copy link
Contributor

Choose a reason for hiding this comment

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

Question) Is there no need for compileTestJava to depend on generateSources (or compileJava)?
I realize that this is just a copy of tomcat8, but this seemed odd 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

IIUC, compileTestJava depends compileJava by the Java Plugin.
https://docs.gradle.org/current/userguide/java_plugin.html
So we don't need an additional dependency for them.

./gradlew :tomcat9:compileTestJava --dry-run
:core:compileJava SKIPPED
:junit4:copyJunitSources SKIPPED
:junit4:generateSources SKIPPED
:junit4:compileJava SKIPPED
:junit5:compileJava SKIPPED
:testing-internal:compileJava SKIPPED
:tomcat9:generateSources SKIPPED
:tomcat9:compileJava SKIPPED
:tomcat9:versionProperties SKIPPED
:tomcat9:processResources SKIPPED
:tomcat9:classes SKIPPED
:tomcat9:compileTestJava SKIPPED

Copy link
Member

@trustin trustin left a comment

Choose a reason for hiding this comment

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

LGTM once the conflicts are resolved. Thanks for adding this long-awaited module!

Copy link
Member

@minwoox minwoox left a comment

Choose a reason for hiding this comment

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

Great job, @ikhoon!
Thanks a lot! 😄

Copy link
Contributor

@jrhee17 jrhee17 left a comment

Choose a reason for hiding this comment

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

Looks really nice! Thanks @ikhoon ! 👍 🚀 🙇

@ikhoon
Copy link
Contributor Author

ikhoon commented Mar 28, 2023

Thanks for the review. I missed pushing some changes that should be checked in before the final review. 224489a (#4574) The changes are trivial ones related to Jacoco and Javadoc.

Copy link
Contributor

@jrhee17 jrhee17 left a comment

Choose a reason for hiding this comment

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

Still looks good 👍

Copy link
Member

@trustin trustin left a comment

Choose a reason for hiding this comment

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

Still LGTM 🚀

@ikhoon ikhoon merged commit 57295d3 into line:main Mar 28, 2023
@ikhoon ikhoon deleted the spring-boot3 branch March 28, 2023 09:18
ikhoon added a commit to ikhoon/armeria that referenced this pull request Mar 28, 2023
Motivation:

Spring Boot 3 has been released and we added new modules for Spring Boot 3 line#4574.
Spring also stopped support for Spring Boot 1 a long time ago.
https://spring.io/blog/2018/07/30/spring-boot-1-x-eol-aug-1st-2019
See line#4651 for the details

Modifications:

- Remove `boot1-autoconfigure` and `boot1-starter` modules

Result:

- You no longer use Spring 1 integration with the lastet Armeria version.
- Closes line#4651
trustin pushed a commit that referenced this pull request Apr 5, 2023
Motivation:

Spring Boot 3 has been released and we added new modules for Spring Boot 3 #4574. Spring also stopped support for Spring Boot 1 a long time ago. https://spring.io/blog/2018/07/30/spring-boot-1-x-eol-aug-1st-2019 See #4651 for the details

Modifications:

- Remove `boot1-autoconfigure` and `boot1-starter` modules

Result:

- You no longer use Spring 1 integration with the latest Armeria version.
- Closes #4651
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants