Skip to content

Conversation

@carlesarnal
Copy link
Member

Summary

  • Replace all printStackTrace() calls with proper SLF4J logging throughout the codebase
  • Add slf4j-api dependency to schema-resolver module

Root Cause

The codebase contained 18 printStackTrace() calls across 13 files, which is not a best practice as it outputs to stderr without proper log formatting, levels, or integration with the logging infrastructure.

Changes

Production code:

  • ERCache.java: Added SLF4J logger, replaced with log.error() and log.debug()
  • GraphQLContentValidator.java: Added SLF4J logger, replaced with log.debug()
  • schema-resolver/pom.xml: Added slf4j-api dependency

Test code:

  • SimpleAuthIT.java: Replaced with logger.warn() (using base class logger)
  • MigrationTestsDataInitializer.java: Added logger, replaced with log.error()
  • GenerateCanonicalHashImportIT.java: Added logger, replaced with log.error()
  • ImportExportTest.java: Added logger, replaced with log.warn() and log.debug()
  • AllYamlTest.java: Added logger, replaced with log.error()
  • TestUtils.java: Replaced with log.warn()

Examples:

  • SimpleBroker.java: Replaced with System.err.println()
  • MessagePublisher.java: Removed redundant printStackTrace() (message already printed)
  • MtlsClientDemo.java: Replaced with structured error output

Build tools:

  • GenerateAllConfigPartial.java: Added logger, replaced 4 calls with proper logging

Test plan

  • Build compiles successfully
  • No remaining printStackTrace() calls (except auto-generated MavenWrapperDownloader.java)

Fixes #7070

Replace all printStackTrace() calls with proper SLF4J logging throughout
the codebase:

- Production code: Use log.error(), log.warn(), or log.debug() as appropriate
- Test code: Use logger from base class or add SLF4J logger
- Examples: Use System.err.println() for standalone demo apps
- Build tools: Add SLF4J logging

Also added slf4j-api dependency to schema-resolver module.

Fixes Apicurio#7070
@carlesarnal carlesarnal added this to the 3.1.7 milestone Jan 7, 2026
@carlesarnal carlesarnal merged commit ee3a033 into Apicurio:main Jan 7, 2026
94 of 115 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.

Replace printStackTrace() calls with proper logging

1 participant