kevinjqliu opened a new pull request, #18599:
URL: https://github.com/apache/iceberg/pull/18599
Supersedes #17841 by @Denverper (credited as co-author).
#### Problem
Shadow mishandles `META-INF/services` files by default, in two ways:
1. Dropped entries: when two bundled deps ship a service file with the same
name, the jar keeps only the first copy it reads. Providers listed in the other
copies are lost, so `ServiceLoader` can't find them even though their classes
are in the jar.
2. Unrelocated names: when we relocate a package (e.g. Jackson), its classes
move but its service files keep the original names. They point at classes that
no longer exist under those names, and the app's own copy of that library can
pick them up.
This breaks the cloud bundles today:
- Dropped entries (Azure): with Reactor context propagation on (e.g. for
Micrometer tracing), ADLS calls fail (#17841), because the bundle dropped
reactor-core's `ContextAccessor` registration:
```
java.lang.IllegalStateException: No ContextAccessor for contextType: class
reactor.util.context.Context0
```
- Unrelocated names (Azure/GCP): the bundles ship an unrelocated
`com.fasterxml.jackson.databind.Module` file pointing at a `JavaTimeModule`
that isn't there, so any app on the same classpath without
`jackson-datatype-jsr310` that calls `ObjectMapper.findAndRegisterModules()`
fails:
```
java.util.ServiceConfigurationError:
com.fasterxml.jackson.databind.Module: Provider
com.fasterxml.jackson.datatype.jsr310.JavaTimeModule not found
```
#### Fix
Turn on `mergeServiceFiles()` for the aws/azure/gcp bundles. AWS has no
known failure today, but it's included so all cloud bundles behave the same.
#### Why the cloud bundles
We tell users to add the cloud bundles instead of the SDK jars, so they
should just work like the SDK jars do. The SDKs rely on `ServiceLoader` even
though Iceberg doesn't, and merging just makes the bundles register what the
SDK jars would.
#### What changes in the jars
| Bundle | Dropped entries recovered | Service files renamed to shaded names
|
|---|---|---|
| azure-bundle | 2 | 3 |
| gcp-bundle | 26 | 3 |
| aws-bundle | 10 | 0 |
Nothing is dropped, and nothing outside `META-INF/services` changes.
<details>
<summary>Recovered entries</summary>
azure-bundle:
```
META-INF/services/io.micrometer.context.ContextAccessor
conflict: reactor-core and reactor-netty-core both ship this file;
reactor-netty-core's was kept
before: reactor.netty.contextpropagation.ChannelContextAccessor
after: reactor.netty.contextpropagation.ChannelContextAccessor
reactor.util.context.ReactorContextAccessor
<- recovered
META-INF/services/reactor.blockhound.integration.BlockHoundIntegration
conflict: reactor-core and netty-common both ship this file;
reactor-core's was kept
before: reactor.core.scheduler.ReactorBlockHoundIntegration
after: reactor.core.scheduler.ReactorBlockHoundIntegration
org.apache.iceberg.azure.shaded.io.netty.util.internal.Hidden$NettyBlockHoundIntegration
<- recovered
```
gcp-bundle (20 gRPC entries below, plus Jackson XML (2), OpenTelemetry (3),
and BlockHound (1)):
```
META-INF/services/io.grpc.LoadBalancerProvider
before: io.grpc.internal.PickFirstLoadBalancerProvider (1 entry)
after: + grpclb, rls, round_robin, outlier detection, xDS ... (16
entries)
META-INF/services/io.grpc.NameResolverProvider
before: io.grpc.internal.DnsNameResolverProvider (1 entry)
after: + google-c2p, xds, grpclb, unix socket (6
entries)
```
aws-bundle: `SdkWarmUpProvider` from each AWS SDK service client, and the
SDK's internal Jackson CBOR factory.
</details>
<details>
<summary>Renamed service files</summary>
azure-bundle (same for gcp-bundle; also `JsonFactory` and `ObjectCodec`):
```
before: META-INF/services/com.fasterxml.jackson.databind.Module
com.fasterxml.jackson.datatype.jsr310.JavaTimeModule
<- not in the jar
after:
META-INF/services/org.apache.iceberg.azure.shaded.com.fasterxml.jackson.databind.Module
org.apache.iceberg.azure.shaded.com.fasterxml.jackson.datatype.jsr310.JavaTimeModule
```
</details>
#### Test plan
- Diffed `META-INF/services` in each bundle before and after.
- Reproduced both failures with the released bundles, and confirmed they
pass with this PR:
- azure-bundle 1.12.0 with `Hooks.enableAutomaticContextPropagation()` and
a registered `ThreadLocalAccessor`: an ADLS `getProperties()` call fails before
any network I/O.
- azure-bundle and gcp-bundle with an app's own Jackson and no
`jackson-datatype-jsr310`: `ObjectMapper.findAndRegisterModules()` fails.
<details>
<summary>Verify locally</summary>
Quick spot check:
```sh
gh pr checkout 18599
./gradlew :iceberg-azure-bundle:shadowJar
unzip -p azure-bundle/build/libs/iceberg-azure-bundle-*.jar
META-INF/services/io.micrometer.context.ContextAccessor
# expect ChannelContextAccessor and ReactorContextAccessor; main only has
the first
```
Full before/after diff of the bundles:
```sh
# build the bundles and extract each one's META-INF/services into $1/<jar
name>/
dump_services() {
./gradlew -q :iceberg-aws-bundle:shadowJar :iceberg-azure-bundle:shadowJar
:iceberg-gcp-bundle:shadowJar
mkdir -p "$1"
for jar in *-bundle/build/libs/*.jar; do
unzip -qo "$jar" 'META-INF/services/*' -d "$1/$(basename "$jar" .jar)"
done
}
git worktree add ../iceberg-main main
(cd ../iceberg-main && dump_services /tmp/services-before)
gh pr checkout 18599 && dump_services /tmp/services-after
diff -r -B -w -I '^#' /tmp/services-before /tmp/services-after # ignore
blank lines, whitespace, and comments
```
`>` lines inside an existing service file are recovered entries. `Only in`
pairs are renamed files: the original name in before, the
`org.apache.iceberg...shaded` name in after.
</details>
---
**AI Disclosure**
- Model: Claude Opus 5.5
- Platform/Tool: GitHub Copilot
- Human Oversight: I reviewed all changes
- Prompt Summary: Review #17841 and apply its `mergeServiceFiles()` fix to
the cloud bundles.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]