fix(pricing): bundle snapshot resources into native image#836
Open
ShubhamDX wants to merge 2 commits into
Open
fix(pricing): bundle snapshot resources into native image#836ShubhamDX wants to merge 2 commits into
ShubhamDX wants to merge 2 commits into
Conversation
The bundled pricing-snapshots tree was missing from the GraalVM native-image build, so the standard Floci container (which ships the native binary) had no service codes available — the Pricing snapshot loader silently returned null because the JSON files weren't present at runtime. Two changes: 1. Register `pricing-snapshots/**` under `quarkus.native.resources.includes` so GraalVM bundles every snapshot file into the image. Quarkus's static analysis cannot detect resource paths constructed dynamically (the loader joins `pricing-snapshots/` with a per-call relative path), so an explicit include is required. 2. Read snapshot resources via the class's own `ClassLoader` rather than the thread context loader. In a native image the thread context loader can be the bootstrap loader, which sees no application resources, while the class's loader sees everything bundled into the image. Reported by @cfranzen against floci-io#821 — Pricing service returned no service codes when called via Testcontainers and `load()` produced no log output, indicating the snapshot files were absent rather than malformed. Refs: floci-io#821 (comment)
7 tasks
Contributor
Author
|
Verified locally against the native build: Container logs now show That second line was missing in the broken build — |
Collaborator
|
@ShubhamDX thank you! @cfranzen Could you take a look at this PR? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Reported by @cfranzen on #821: when running Floci as a container, the Pricing service returns no service codes and
PricingService.load()produces no log output at all — symptoms that point to the bundled snapshot files being absent rather than malformed.Root cause: the standard Floci container ships the GraalVM native binary, and
pricing-snapshots/**was never registered as a runtime resource in the native-image config, so GraalVM stripped every JSON file from the image. The classpath read inSnapshotLoader.readJsonreturnednullfor theservices.jsonlookup, which short-circuitsload()before it logs anything.Fix
Two small changes:
quarkus.native.resources.includes. Quarkus's static resource analysis can't detect paths assembled at call time ("pricing-snapshots/" + relativePath), so an explicit include is needed.PricingService.class.getClassLoader()for the snapshot read. In a GraalVM native image the thread context classloader can be the bootstrap loader, which sees no application resources, while the class's own loader always sees what's bundled into the image.Test plan
./mvnw test -Dtest=PricingIntegrationTest— 26/26 green locally on JVM (Java 25)I don't have a local GraalVM toolchain set up to validate the native build directly; CI will exercise the published image path that triggered the report.
Refs: #821 (comment)