Skip to content

Conversation

@jarebudev
Copy link
Contributor

This PR

Enables threads (daemon and non-daemon) to be named as required to aid debugging.

Related Issues

Resolves #1633

Notes

Follow-up Tasks

How to test

@jarebudev jarebudev requested review from a team as code owners November 4, 2025 23:13
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @jarebudev, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the debugging experience by implementing a mechanism to assign meaningful, descriptive names to the various threads utilized throughout the SDK. By centralizing thread creation through a configurable factory, developers can more easily identify and monitor specific background processes, which is crucial for diagnosing concurrency issues and understanding application behavior.

Highlights

  • New Thread Factory: Introduced a new ConfigurableThreadFactory to allow for custom naming of threads created within the SDK, improving debuggability.
  • Thread Naming: Applied the new thread factory to name thread pools in EventProvider, EventSupport, and ProviderRepository with descriptive prefixes like 'openfeature-event-emitter-thread' and 'openfeature-provider-thread'.
  • Daemon Thread Configuration: The ConfigurableThreadFactory also allows explicit configuration of whether created threads should be daemon threads, which was applied to the ProviderRepository's task executor.
  • Unit Tests: Added comprehensive unit tests for the ConfigurableThreadFactory to ensure correct thread naming and daemon status.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Nov 4, 2025

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces descriptive thread names for better debuggability, which is a great improvement. The new ConfigurableThreadFactory is a clean and reusable component that simplifies thread creation logic across the codebase. The changes are well-implemented and include corresponding unit tests. I have one suggestion to improve the robustness of the new thread factory.

Comment on lines +31 to +34
public ConfigurableThreadFactory(String namePrefix, boolean daemon) {
this.namePrefix = namePrefix;
this.daemon = daemon;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For improved robustness, it's a good practice to validate constructor parameters. The namePrefix should not be null or empty to prevent creating threads with malformed names (e.g., -1). Adding a check will make this utility class safer to use in the future.

You could also add a corresponding test case to verify this behavior:

@Test
void shouldThrowOnNullOrEmptyPrefix() {
    assertThatThrownBy(() -> new ConfigurableThreadFactory(null))
        .isInstanceOf(IllegalArgumentException.class);
    assertThatThrownBy(() -> new ConfigurableThreadFactory(""))
        .isInstanceOf(IllegalArgumentException.class);
}
    public ConfigurableThreadFactory(String namePrefix, boolean daemon) {
        if (namePrefix == null || namePrefix.isEmpty()) {
            throw new IllegalArgumentException("Thread name prefix cannot be null or empty.");
        }
        this.namePrefix = namePrefix;
        this.daemon = daemon;
    }

@codecov
Copy link

codecov bot commented Nov 4, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.26%. Comparing base (01a3669) to head (2629c5e).

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #1704      +/-   ##
============================================
+ Coverage     91.93%   93.26%   +1.32%     
- Complexity      517      522       +5     
============================================
  Files            51       52       +1     
  Lines          1265     1276      +11     
  Branches        112      112              
============================================
+ Hits           1163     1190      +27     
+ Misses           64       50      -14     
+ Partials         38       36       -2     
Flag Coverage Δ
unittests 93.26% <100.00%> (+1.32%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

@chrfwow chrfwow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice

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.

Use Descriptive Thread Names

2 participants