Skip to content

fix(core): stop splitting io.spiffe.workloadapi.internal across modules - #523

Merged
maxlambrecht merged 4 commits into
spiffe:mainfrom
cvas22:split-package-provider
Nov 20, 2026
Merged

maxlambrecht merged 4 commits into
spiffe:mainfrom
cvas22:split-package-provider

Conversation

@cvas22

@cvas22 cvas22 commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #108

The grpc-netty-* modules each shipped their own GrpcManagedChannelFactory and ManagedChannelWrapper in io.spiffe.workloadapi.internal, the same package core uses, and core just got whichever copy came first on the classpath. That split package is what breaks consumers on the module path.

ManagedChannelWrapper now lives in core and takes a plain close hook instead of a Netty EventLoopGroup, since the Linux module uses shaded Netty and the macOS ones don't. Core has a small GrpcChannelProvider interface, each module implements it in its own package (internal.linux, internal.macos, internal.macos.aarch64) and registers it in META-INF/services, and GrpcManagedChannelFactory loads it with ServiceLoader. It picks the provider that supports the current OS and arch, and falls back to the first one found, so a TCP address still works with whatever module you have and a Unix socket on the wrong platform fails the same way it does today. If a provider can't be loaded and nothing else is found, that error is the cause of the "no provider" exception. DefaultWorkloadApiClient is unchanged, and core only needs a grpc-netty module at test time now.

Tests cover provider selection, the fallback, load errors and the close hook in core, plus a test per module that its provider is registered and builds a TCP channel. I ran the Build workflow on my fork, linux and macOS on 17, 21 and 25, all green.

Notes

Everything that moved is under internal, which japicmp already skips, so nothing public changes. The modules only compileOnly core, so their published POMs stay the same. Mixing a new core with an old grpc-netty-* jar won't work, but the README and the BOM already say those versions have to match.

@maxlambrecht maxlambrecht left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for putting this together! The package split and close hook look right, and the helper SPIRE job already exercises service loading through the shaded helper JAR on Linux.

Looking at selection, the built-in providers have mutually exclusive platform checks, so choosing the first supported provider works for the current implementations.

Before merging, could you add a regression test that compiles and runs a small named-module consumer against core, one transport, and their runtime dependencies on the module path, including channel creation and close? That would cover the original split-package failure and service discovery.

It would also help to note in the changelog that core and the transport artifact need to be upgraded together, since an old transport JAR still contains the original shared package.

@cvas22
cvas22 force-pushed the split-package-provider branch from 91acd12 to 9d8671d Compare November 19, 2026 04:01
@cvas22

cvas22 commented Nov 19, 2026

Copy link
Copy Markdown
Contributor Author

thx for the review. I added ModulePathTest to the Linux transport module, it puts core, the transport and their runtime deps on the module path in their own layer and creates and closes a channel through core. It fails if I put a class back into the shared package. The changelog now says to upgrade core and the transport artifact together. It only covers the Linux transport, I haven't added a macOS equivalent.

@cvas22
cvas22 force-pushed the split-package-provider branch from fd3e1e4 to f958b5a Compare November 19, 2026 07:05

@maxlambrecht maxlambrecht left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for adding the regression test and changelog note. I found two issues in the test setup:

  • ModulePathTest skips on JDK 22 even though jdk.crypto.ec exists, because it isn’t resolved in the boot layer. Reintroducing the split package still leaves the build green with the test skipped. Using ModuleFinder.ofSystem() as the resolution fallback makes it run. Please include system modules in resolution and only skip when the module is actually absent.
  • Accessing configurations.modulePath inside doFirst fails when Gradle’s configuration cache is enabled. Moving the system-property assignment into task configuration, while keeping the tracked inputs, fixes it.
    The runtime changes still look good. These are the remaining issues I found before approval.

…ules

The grpc-netty-* modules each shipped their own GrpcManagedChannelFactory
and ManagedChannelWrapper in io.spiffe.workloadapi.internal, the same
package core uses, and core picked whichever came first on the classpath.
That split package breaks consumers on the Java module path.

Move ManagedChannelWrapper into core with a plain close hook, add a
GrpcChannelProvider interface, and have each grpc-netty module register
its provider in its own package through META-INF/services. Core loads it
with ServiceLoader and picks the one supporting the current OS and arch,
falling back to the first one found so TCP addresses keep working.
Core no longer needs a grpc-netty module on its compile classpath.

Signed-off-by: Srinivas Chippagiri <cvas22@gmail.com>
Signed-off-by: Srinivas Chippagiri <cvas22@gmail.com>
Signed-off-by: Srinivas Chippagiri <cvas22@gmail.com>
@maxlambrecht
maxlambrecht force-pushed the split-package-provider branch from f958b5a to ed51651 Compare November 19, 2026 16:13
@cvas22

cvas22 commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor Author

thx, both fixed in e70e425. Resolution now falls back to the system modules and only skips when jdk.crypto.ec is really missing, and the module path property is set at configuration time. It runs here with the configuration cache on.

…ration time

Signed-off-by: Srinivas Chippagiri <cvas22@gmail.com>

@maxlambrecht maxlambrecht left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for addressing both points.

LGTM!

@maxlambrecht
maxlambrecht merged commit f28a870 into spiffe:main Nov 20, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The java-spiffe modules contain split packages which break the Java Modules (JPMS)

2 participants