Skip to content

Conversation

onobc
Copy link
Contributor

@onobc onobc commented Sep 20, 2025

Add Spring gRPC support

This commit introduces support for Spring gRPC by moving the autoconfiguration, test, and starter modules from Spring gRPC to Spring Boot (here).

Note

The relevant docs from Spring gRPC are not included in this proposal (will be in a subsequent PR).

Here is a list of things to consider adding after this proposal is merged:

TODOs

  • (required) Add docs (we will handle this as we are familiar w/ the content that is currently in the Spring gRPC docs)
  • (Improvement) get hardcoded grpc/proto version out of grpc smoke test
  • (Improvement) add aggregate server enabled to ConditionalOnGrpcServerEnavled (e.g. spring.grpc.server.(|reflection|health|observation).enabled
  • (Improvement) if we do not do the above (agg server enabled) we should rename COGSE because it is already also checking COC(BindableService) + property not set to false
  • (Improvement) Beef up tests for grpc test components in spring-boot-test-autoconfigure module
    • @LocalGrpcPort
    • ServerPortInfoApplicationContextInitializer
    • InProcessTransportContextCustomizerFactory
    • @AutoConfigureInProcessTransport
      • Without @ACIPT neither AC nor IPTCC fires
      • With @ACIPT(true|) AC and IPTCC fires
      • With @ACIPT(false) neither AC nor IPTCC fires
      • With @ACIPT(true|) user can set enabled prop to false and neither AC nor IPTCC fires
  • (Improvement) Re-enable the ActuatorHealthAdapterTests. They are disabled because HealthDescriptor is now abstract and sealed and as such we are unable to mock it or create an actual instance as IndicatedHealthDescriptor is package-protected.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Sep 20, 2025
exclude "smoketest/grpc/proto"
}

// FIXME get from 'protobuf-java-version' from dep mgmt
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 were doing this test outside of Spring Boot I would use dependencyManagement.importedProperties. I banged on this for at least an hour and cut my losses and figured the reviewer will know a simple way to do this.

@onobc onobc force-pushed the cbono-grpc-autoconfig-springgrpc-GH-234 branch 2 times, most recently from a4e4d21 to 76ac9fb Compare September 23, 2025 16:51
onobc referenced this pull request in philwebb/spring-boot Sep 24, 2025
This commit introduces support for Spring gRPC by moving the
autoconfiguration, test, and starter modules from Spring gRPC
to Spring Boot (here).

The relavant docs from Spring gRPC are not included in this
commit and will be available in a subsequent commit.

Signed-off-by: onobc <[email protected]>
Updates the following gRPC related library versions:

- `grpc-bom` from `1.74.0` to `1.75.0`
- `protobuf-bum` from `4.31.1` to `4.32.1`

Signed-off-by: onobc <[email protected]>
This updates the gRPC Kotlin version from `1.4.3` to `1.5.0`

Signed-off-by: onobc <[email protected]>
Updates the gRPC and protobuf versions in the gRPC smoke test:

- `grpc-bom` from `1.74.0` to `1.75.0`
- `protobuf-bum` from `4.31.1` to `4.32.1`

Signed-off-by: onobc <[email protected]>
Uses `org.springframework.boot.EnvironmentPostProcessor` instead of the
deprecated `org.springframework.boot.env.EnvironmentPostProcessor` key
in `spring.factories` for the `spring-boot-grpc-server` module.

Signed-off-by: onobc <[email protected]>
The config prop name was mismatched in the both the gRPC client
and server modules additional-spring-configuration-metadata.json
files. This makes them consistent using the singular form of the
property `spring.grpc.(client|server).observation.enabled`.

Signed-off-by: onobc <[email protected]>
Signed-off-by: onobc <[email protected]>
Moves the grpc test code into its own module (`spring-boot-grc-test`)
due to the modularization of the test module.

Signed-off-by: onobc <[email protected]>
@onobc onobc force-pushed the cbono-grpc-autoconfig-springgrpc-GH-234 branch from 32331a9 to a1c2b04 Compare September 25, 2025 22:49
Addresses the following:

- nits
- visibility (move to package protected etc..)
- javadocs
- make server properties anemic

Does not cover the following points:

- rename / restructure the ConditionalOn... for server
- observation API verify/check on direction
- security concerns (need more review but should be good the way it is)

Signed-off-by: onobc <[email protected]>
Consolidate the conditional annotations into an aggregate that checks
for server and service enabled as well as one that checks that
Spring gRPC is on the classpath.

Signed-off-by: onobc <[email protected]>
Collapses the GrpcCodecConfiguration into the parent package to avoid
exposing it publicly.

Signed-off-by: onobc <[email protected]>
Collapses the single bean registered by ClientInterceptorsConfiguration into
the 2 usages to avoid a public configuration class.

Signed-off-by: onobc <[email protected]>
- only use default de/compressor registry when user provides no custom de/compressor
- update tests accordingly

Signed-off-by: onobc <[email protected]>
- only use default de/compressor registry when user provides no custom de/compressor
- update tests accordingly

Signed-off-by: onobc <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: waiting-for-triage An issue we've not yet triaged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants