Skip to content

Propagate TrustedChecksumException in IndexFile - #7515

Open
chrisrueger wants to merge 3 commits into
bndtools:masterfrom
chrisrueger:trusted-checksum-show-error-in-build
Open

chrisrueger wants to merge 3 commits into
bndtools:masterfrom
chrisrueger:trusted-checksum-show-error-in-build

Conversation

@chrisrueger

Copy link
Copy Markdown
Contributor

Ensure TrustedChecksumException is properly thrown rather than silently logged. This includes:

  • Check result of serialize() in open() and propagate any failure
  • Rethrow TrustedChecksumException in recover() handler before logging
  • Rethrow TrustedChecksumException in failed() method before returning failure map

Checksum validation failures are critical and should fail the operation.

This now really fails the build as well as shows an error in the UI

@chrisrueger
chrisrueger force-pushed the trusted-checksum-show-error-in-build branch from 01c548a to deb02ca Compare October 31, 2026 06:58
Ensure TrustedChecksumException is properly thrown rather than silently logged. This includes:

- Check result of serialize() in open() and propagate any failure
- Rethrow TrustedChecksumException in recover() handler before logging
- Rethrow TrustedChecksumException in failed() method before returning failure map

Checksum validation failures are critical and should fail the operation.

This now really fails the build as well as shows an error in the UI

Signed-off-by: Christoph Rueger <chrisrueger@gmail.com>
Refactor checksum policy initialization to use constructor parameter instead of setter method. This makes the policy immutable (final field) and simplifies initialization flow in BndPomRepository and MavenBndRepository. The old single-parameter constructor is deprecated in favor of the new one accepting ChecksumPolicy, and setTrustedChecksumsPolicy() is removed from MavenRepository.

Signed-off-by: Christoph Rueger <chrisrueger@gmail.com>
@chrisrueger
chrisrueger force-pushed the trusted-checksum-show-error-in-build branch from deb02ca to 3aedd16 Compare October 31, 2026 07:07
@chrisrueger

Copy link
Copy Markdown
Contributor Author

Now with this PR a gradle build fails with this message. Before the build just failed but not told why.

error  : workspace3 :Init for MavenBndRepository failed TrustedChecksum Strict checksum policy enabled but no checksum entry found for: org.slf4j:slf4j-simple:2.0.8, snapshotUrl="https://oss.sonatype.org/content/repositories/snapshots/";releaseUrl="https://repo.maven.apache.org/maven2/";index="/Users/me/Documents/development/git/bnd/bndtools.test/workspace3/cnf/ext/runtime.mvn";readOnly=true;checksumPolicy=strict;name="OSGI R8 - Runtime Distro"'

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':org.bndtools.demo.webapp:compileJava'.
> org.bndtools.demo.webapp has errors, 3 errors were reported

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 331ms
1 actionable task: 1 executed

Correct documentation to clarify that checksumRecord operates after successful initialization, not during. Add notes on the recommended bootstrap flow: use checksumPolicy=lenient with checksumRecord=true to generate checksums, then switch to strict mode for enforcement. This prevents confusion about initialization order and why strict mode with missing checksums fails before recording can run.

Signed-off-by: Christoph Rueger <chrisrueger@gmail.com>

This branch has not been deployed

No deployments
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.

1 participant