Skip to content

Log unknown exceptions in FallbackHandler unconditionally - #428

Open
yuxndjhdh wants to merge 1 commit into
spring-projects:mainfrom
yuxndjhdh:fix/426-fallbackhandler-exception-logging
Open

Log unknown exceptions in FallbackHandler unconditionally#428
yuxndjhdh wants to merge 1 commit into
spring-projects:mainfrom
yuxndjhdh:fix/426-fallbackhandler-exception-logging

Conversation

@yuxndjhdh

Copy link
Copy Markdown

Remove the logger.isDebugEnabled() guard around logger.error("Unknown exception", exception) in GrpcExceptionHandlerInterceptor.FallbackHandler.

Why

  • The fallback branch is only reached when no registered GrpcExceptionHandler recognized the exception, i.e. a genuinely unhandled server-side fault.
  • Gating an ERROR log behind a DEBUG check inverts the usual convention. At the default INFO level nothing is logged, so the causing exception is silently swallowed - exactly the case operators most need to see.
  • The returned Status and wire behavior are unchanged; teams that relied on the previous silence can still disable this logger through normal logging configuration.

How it was checked

  • Added GrpcExceptionHandlerInterceptorTests#unknownExceptionIsLoggedWhenNoHandlerMatches asserting the ERROR record is emitted.
  • spring-grpc-core full suite: 167 tests, 0 failures.
  • ./mvnw -pl spring-grpc-core spring-javaformat:validate passes.

Closes gh-426

FallbackHandler.handleException only logged when logger.isDebugEnabled()
was true before invoking logger.error(...). Gating an ERROR-level log
behind a DEBUG check inverts the usual convention: when nothing else
handles the exception the fallback branch silently swallowed the causing
exception at the default (INFO) logging level. Log unconditionally at
ERROR so operators always see genuinely unhandled server exceptions; the
returned Status is unchanged and the logger can still be silenced through
normal logging configuration.

Closes: spring-projectsgh-426
Signed-off-by: yuxndjhdh <148313905+yuxndjhdh@users.noreply.github.com>
@yuxndjhdh
yuxndjhdh force-pushed the fix/426-fallbackhandler-exception-logging branch from c06a81e to 7c960ad Compare September 9, 2026 01:05
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.

GrpcExceptionHandlerInterceptor.FallbackHandler silently drops the causing exception unless the logger is explicitly at DEBUG

1 participant