Reuse VirtualHostBuilder on the same hostnamePattern
Motivation:
I registered each virtual host with the same hostname, the registered routes cannot be not found. Because VirtualHostBuilder creates new builder even if hostname is the same. However, it does reuse them on the same port.
So, I think it's better to reuse them on the same hostname.
Modifications:
ServerBuilder.virtualHost(hostnamePattern)andServerBuilder.virtualHost(defaultHostname, hostnamePattern)checks whether there isbuilderswith the same hostname. If there is, returns this builder.
Result:
- Reuse
VirtualHostBuilderon the same hostname. - Even if you register each one on a virtual host with the same hostname, they will be merged.
๐ Build Scanยฎ (commit: 33630faf637607483ab753e890723dcc799eeda6)
| Job name | Status | Build Scanยฎ |
|---|---|---|
| build-windows-latest-jdk-19 | โ | https://ge.armeria.dev/s/ipk5uvwhx7mqg |
| build-self-hosted-unsafe-jdk-8 | โ (failure) | https://ge.armeria.dev/s/hitgjcglcsyee |
| build-self-hosted-unsafe-jdk-17-min-java-17-coverage | โ | https://ge.armeria.dev/s/yhbdtw5o2clse |
| build-self-hosted-unsafe-jdk-17-min-java-11 | โ | https://ge.armeria.dev/s/34cbrqddglqli |
| build-self-hosted-unsafe-jdk-17-leak | โ | https://ge.armeria.dev/s/3jlcdhfdi25oi |
| build-self-hosted-unsafe-jdk-11 | โ | https://ge.armeria.dev/s/6hrvtkpzq5g4c |
| build-macos-12-jdk-19 | โ | https://ge.armeria.dev/s/xzeyacjvivcn2 |
Codecov Report
Attention: Patch coverage is 80.00000% with 7 lines in your changes are missing coverage. Please review.
Project coverage is 74.09%. Comparing base (
8678567) to head (283b7ec). Report is 16 commits behind head on main.
Additional details and impacted files
@@ Coverage Diff @@
## main #5418 +/- ##
============================================
+ Coverage 74.04% 74.09% +0.04%
- Complexity 20871 20986 +115
============================================
Files 1809 1819 +10
Lines 76857 77332 +475
Branches 9809 9880 +71
============================================
+ Hits 56912 57300 +388
- Misses 15304 15375 +71
- Partials 4641 4657 +16
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
gentle ping @yejinio ๐
I've added a small commit which
- Deprecates
ServerBuilder#virtualHostmethods that doesn't supportVirtualHostBuilderreuse - Adds a
ServerBuilder#withVirtualHostwhich supportsVirtualHostBuilderreuse - Deprecates
VirtualHostBuilder#hostnamePatternwhich makesVirtualHostBuilderreuse ambiguous
Let me know if the changes don't make sense ๐ https://github.com/line/armeria/pull/5418/commits/0d0edef32cefac38f31ae7d525bcfd57e7cc3311