jenkinsci / datadog-plugin

A Jenkins plugin used to forward metrics, events, and service checks to an account at Datadog, automatically.
https://plugins.jenkins.io/datadog/
MIT License
30 stars 48 forks source link

Fix stack overflow on initialising DatadogTaskListenerDecorator #396

Closed nikita-tkachenko-datadog closed 5 months ago

nikita-tkachenko-datadog commented 5 months ago

Requirements for Contributing to this repository

What does this PR do?

Fixes stack overflow on initialising DatadogTaskListenerDecorator:

  1. BuildData instance construction is started
  2. EnvActionImpl#getEnvironment() is called
  3. Inside this call run's TaskListener is initialized
  4. Once TaskListener is created, it is wrapped with DatadogTaskListenerDecorator
  5. The decorator starts creating another BuildData instance
  6. The steps repeat indefinitely from point 1

The example stack trace can be found here.

The EnvActionImpl#getEnvironment() call is replaced with EnvActionImpl#getOverriddenEnvironment(), which only returns the env vars that were overridden in that action. The latter call does not trigger task listener initialisation, and allows to examine the right env vars.

Description of the Change

Alternate Designs

Possible Drawbacks

Verification Process

Additional Notes

Release Notes

Review checklist (to be filled by reviewers)