Fix NPE in DatabaseClientDecorator when JDBC connection has no db type - #12371
Open
dougqh wants to merge 1 commit into
Open
Fix NPE in DatabaseClientDecorator when JDBC connection has no db type#12371dougqh wants to merge 1 commit into
dougqh wants to merge 1 commit into
Conversation
Contributor
🟢 Java Benchmark SLOs — All performance SLOs passed
PR vs. master results
Commit: Load and DaCapo benchmarks can be triggered manually in the GitLab pipeline. Results will appear in the Benchmarking Platform UI after completion. |
dougqh
force-pushed
the
dougqh/fix-database-client-decorator-npe
branch
from
September 2, 2026 01:10
343288d to
bec931e
Compare
processDatabaseType/dbService dereferenced the NamingEntry returned by CACHE.computeIfAbsent(dbType, NamingEntry::new) without checking for null. FixedSizeCache.computeIfAbsent returns null for a null key without invoking the producer, so a null dbType() (e.g. an undetermined DBInfo.getType()) led to a NullPointerException in tracing instrumentation instead of a graceful no-op. Guard on dbType == null directly instead of inferring it from the cache's return value, and add a test exercising both methods with a null dbType. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
dougqh
force-pushed
the
dougqh/fix-database-client-decorator-npe
branch
from
September 2, 2026 01:20
bec931e to
0dd0abe
Compare
dougqh
marked this pull request as ready for review
September 2, 2026 01:28
This comment has been minimized.
This comment has been minimized.
Contributor
There was a problem hiding this comment.
More details
The null guards prevent both null dereferences. They keep the existing behavior for non-null database types.
🤖 Datadog Autotest · Commit 0dd0abe · What is Autotest? · @DataDog review to ask questions · Any feedback? Reach out in #autotest
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.
What Does This Do
Guards
DatabaseClientDecorator.processDatabaseType()anddbService()against anulldbType, instead of letting them NPE.CACHE.computeIfAbsent(dbType, NamingEntry::new)returnsnullfor anullkey without invoking the producer (FixedSizeCache.computeIfAbsent,internal-api/.../FixedSizeCache.java:71-73). WhendbTypeisnull— e.g.JDBCDecorator.onConnectionpassing aDBInfo.getType()that couldn't be determined — the returnedNamingEntrywas dereferenced immediately afterward, throwing an NPE inside tracer instrumentation instead of degrading gracefully.processDatabaseType/dbService: checkdbType == nullup front and return early, rather than inferring the null case from the cache's return value.DatabaseClientDecoratorNullDbTypeTestcovering both methods with anulldbType.Motivation
Fixes a NullPointerException reported in Error Tracking (issue, 1300+ occurrences, first seen 2026-02-16, service
mainframe-gatewayvia JDBC instrumentation):Additional Notes
/techdebtand/perf-reviewboth came back clean: no duplication/complexity concerns, and the null-guards are a strict improvement on the previously-crashing path with no added cost on the normal path.🤖 Generated with Claude Code
Contributor Checklist
type:and (comp:orinst:) labels in addition to any other useful labelsclose,fix, or any linking keywords when referencing an issueJira ticket: [PROJ-IDENT]