Skip to content

Commit 4a446d1

Browse files
amarzialidevflow.devflow-routing-intake
andauthored
Fix NPE in PayloadDispatcherImpl (#11196)
# What Does This Do Fixes: ``` java.lang.NullPointerException at writer.PayloadDispatcherImpl.addTrace(PayloadDispatcherImpl.java:71) ``` Since `mapper` and `packer` are set on the same codePath, hence they need both to be nullChecked # Motivation # Additional Notes # Contributor Checklist - Format the title according to [the contribution guidelines](https://github.com/DataDog/dd-trace-java/blob/master/CONTRIBUTING.md#title-format) - Assign the `type:` and (`comp:` or `inst:`) labels in addition to [any other useful labels](https://github.com/DataDog/dd-trace-java/blob/master/CONTRIBUTING.md#labels) - Avoid using `close`, `fix`, or [any linking keywords](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword) when referencing an issue Use `solves` instead, and assign the PR [milestone](https://github.com/DataDog/dd-trace-java/milestones) to the issue - Update the [CODEOWNERS](https://github.com/DataDog/dd-trace-java/blob/master/.github/CODEOWNERS) file on source file addition, migration, or deletion - Update [public documentation](https://docs.datadoghq.com/tracing/trace_collection/library_config/java/) with any new configuration flags or behaviors Jira ticket: [PROJ-IDENT] ***Note:*** **Once your PR is ready to merge, add it to the merge queue by commenting `/merge`.** `/merge -c` cancels the queue request. `/merge -f --reason "reason"` skips all merge queue checks; please use this judiciously, as some checks do not run at the PR-level. For more information, see [this doc](https://datadoghq.atlassian.net/wiki/spaces/DEVX/pages/3121612126/MergeQueue). <!-- # Opening vs Drafting a PR: When opening a pull request, please open it as a draft to not auto assign reviewers before you feel the pull request is in a reviewable state. # Linking a JIRA ticket: Please link your JIRA ticket by adding its identifier between brackets (ex [PROJ-IDENT]) in the PR description, not the title. This requirement only applies to Datadog employees. --> Co-authored-by: devflow.devflow-routing-intake <devflow.devflow-routing-intake@kubernetes.us1.ddbuild.io>
1 parent 0d1c44d commit 4a446d1

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

dd-trace-core/src/main/java/datadog/trace/common/writer/PayloadDispatcherImpl.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,13 @@ private void selectMapper() {
7979
if (mapperDiscovery.getMapper() == null) {
8080
mapperDiscovery.discover();
8181
}
82-
8382
mapper = mapperDiscovery.getMapper();
84-
if (null != mapper && null == packer) {
85-
batchTimer =
86-
monitoring.newTimer("tracer.trace.buffer.fill.time", "endpoint:" + mapper.endpoint());
87-
packer = new MsgPackWriter(new FlushingBuffer(mapper.messageBufferSize(), this));
88-
batchTimer.start();
89-
}
83+
}
84+
if (null == packer && null != mapper) {
85+
batchTimer =
86+
monitoring.newTimer("tracer.trace.buffer.fill.time", "endpoint:" + mapper.endpoint());
87+
packer = new MsgPackWriter(new FlushingBuffer(mapper.messageBufferSize(), this));
88+
batchTimer.start();
9089
}
9190
}
9291

0 commit comments

Comments
 (0)