Skip to content

refactor: Move RebindSafeMBeanServer to presto-common#27173

Merged
nishithakbhaskaran merged 1 commit intoprestodb:masterfrom
KNagaVivek:move-mbean-common
Mar 4, 2026
Merged

refactor: Move RebindSafeMBeanServer to presto-common#27173
nishithakbhaskaran merged 1 commit intoprestodb:masterfrom
KNagaVivek:move-mbean-common

Conversation

@KNagaVivek
Copy link
Copy Markdown
Contributor

@KNagaVivek KNagaVivek commented Feb 19, 2026

Description

Move RebindSafeMBeanServer from individual connector modules to presto-common (util package) to eliminate code duplication.

Motivation and Context

During code review, it was identified that RebindSafeMBeanServer was duplicated across 5 different connector modules (hive, cassandra, jmx, thrift-connector, and pinot-toolkit). This utility class wraps MBeanServer to handle MBean re-registration scenarios gracefully.

Impact

No functional changes. This is an internal refactoring only

Test Plan

Verified that all affected connectors build successfully.

Contributor checklist

  • Please make sure your submission complies with our contributing guide, in particular code style and commit standards.
  • PR description addresses the issue accurately and concisely. If the change is non-trivial, a GitHub Issue is referenced.
  • Documented new properties (with its default value), SQL syntax, functions, or other functionality.
  • If release notes are required, they follow the release notes guidelines.
  • Adequate tests were added if applicable.
  • CI passed.
  • If adding new dependencies, verified they have an OpenSSF Scorecard score of 5.0 or higher (or obtained explicit TSC approval for lower scores).

Release Notes

== NO RELEASE NOTE ==

Summary by Sourcery

Consolidate the RebindSafeMBeanServer utility into presto-common and update connectors to use the shared implementation, eliminating duplicated code.

Enhancements:

  • Move RebindSafeMBeanServer to presto-common util package and update Hive, Cassandra, Iceberg, JMX, Pinot, and Thrift connector factories to reference the shared implementation.
  • Remove connector-local RebindSafeMBeanServer classes to centralize MBean rebind handling logic.

Build:

  • Add the Airlift logging dependency to presto-common for the shared RebindSafeMBeanServer utility.
  • Remove unused error_prone_annotations dependencies from the JMX and Thrift connector module POMs.

@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai bot commented Feb 19, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Refactors the RebindSafeMBeanServer utility into presto-common and updates all connectors to use the shared implementation while cleaning up now-unnecessary module-level dependencies and duplicated classes.

Class diagram for shared RebindSafeMBeanServer and connector factories

classDiagram
    class MBeanServer

    class RebindSafeMBeanServer {
    }

    class HiveConnectorFactory {
    }

    class CassandraConnectorFactory {
    }

    class JmxConnectorFactory {
    }

    class ThriftConnectorFactory {
    }

    class PinotConnectorFactory {
    }

    RebindSafeMBeanServer --> MBeanServer : wraps

    HiveConnectorFactory --> RebindSafeMBeanServer : uses
    CassandraConnectorFactory --> RebindSafeMBeanServer : uses
    JmxConnectorFactory --> RebindSafeMBeanServer : uses
    ThriftConnectorFactory --> RebindSafeMBeanServer : uses
    PinotConnectorFactory --> RebindSafeMBeanServer : uses
Loading

File-Level Changes

Change Details Files
Centralize RebindSafeMBeanServer implementation in presto-common util package and wire it into all connector factories that use it.
  • Add RebindSafeMBeanServer class under a common util package, preserving existing behavior of wrapping MBeanServer to tolerate re-registration
  • Update Hive, Cassandra, Iceberg, JMX, Pinot, and Thrift connector factories to import and use the shared RebindSafeMBeanServer from presto-common instead of local copies
presto-common/src/main/java/com/facebook/presto/common/util/RebindSafeMBeanServer.java
presto-hive/src/main/java/com/facebook/presto/hive/HiveConnectorFactory.java
presto-cassandra/src/main/java/com/facebook/presto/cassandra/CassandraConnectorFactory.java
presto-iceberg/src/main/java/com/facebook/presto/iceberg/InternalIcebergConnectorFactory.java
presto-jmx/src/main/java/com/facebook/presto/connector/jmx/JmxConnectorFactory.java
presto-pinot-toolkit/src/main/java/com/facebook/presto/pinot/PinotConnectorFactory.java
presto-thrift-connector/src/main/java/com/facebook/presto/connector/thrift/ThriftConnectorFactory.java
Remove duplicated RebindSafeMBeanServer classes from individual connector modules.
  • Delete connector-specific RebindSafeMBeanServer implementations that duplicated the same logic
  • Ensure no remaining references to the deleted classes in connector code
presto-hive/src/main/java/com/facebook/presto/hive/RebindSafeMBeanServer.java
presto-cassandra/src/main/java/com/facebook/presto/cassandra/RebindSafeMBeanServer.java
presto-jmx/src/main/java/com/facebook/presto/connector/jmx/util/RebindSafeMBeanServer.java
presto-pinot-toolkit/src/main/java/com/facebook/presto/pinot/RebindSafeMBeanServer.java
presto-thrift-connector/src/main/java/com/facebook/presto/connector/thrift/util/RebindSafeMBeanServer.java
Align module dependencies with the new common location of RebindSafeMBeanServer.
  • Add airlift log dependency to presto-common so the shared RebindSafeMBeanServer can use logging with provided scope
  • Remove now-unnecessary error_prone_annotations dependencies from presto-jmx and presto-thrift-connector poms that were previously needed by their local RebindSafeMBeanServer versions
presto-common/pom.xml
presto-jmx/pom.xml
presto-thrift-connector/pom.xml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • Since presto-common now depends on com.facebook.airlift:log (even with provided scope), consider whether the logging in RebindSafeMBeanServer can be removed or injected from callers to keep presto-common free of connector-level logging dependencies.
  • Double-check that all previous package paths for RebindSafeMBeanServer usages (e.g., ...connector.jmx.util, ...connector.thrift.util, etc.) have been updated consistently to the new presto-common location so there are no lingering references or duplicated helpers.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Since `presto-common` now depends on `com.facebook.airlift:log` (even with `provided` scope), consider whether the logging in `RebindSafeMBeanServer` can be removed or injected from callers to keep `presto-common` free of connector-level logging dependencies.
- Double-check that all previous package paths for `RebindSafeMBeanServer` usages (e.g., `...connector.jmx.util`, `...connector.thrift.util`, etc.) have been updated consistently to the new `presto-common` location so there are no lingering references or duplicated helpers.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@Dilli-Babu-Godari Dilli-Babu-Godari added the from:IBM PR from IBM label Feb 19, 2026
@prestodb-ci prestodb-ci requested review from a team and Joe-Abraham and removed request for a team February 19, 2026 11:26
@prestodb-ci
Copy link
Copy Markdown
Contributor

Saved that user @KNagaVivek is from IBM

@Dilli-Babu-Godari Dilli-Babu-Godari removed the request for review from Joe-Abraham February 19, 2026 11:27
Copy link
Copy Markdown
Member

@agrawalreetika agrawalreetika left a comment

Choose a reason for hiding this comment

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

Clean up lgtm.

I have one suggestion - I think moving @SuppressWarnings("deprecation") from class-level to method-level for the three deprecated deserialize() methods would be better. Since this provides more targeted suppression.

@KNagaVivek
Copy link
Copy Markdown
Contributor Author

Thanks @agrawalreetika

Moved @SuppressWarnings("deprecation") from class-level to method-level.

Move RebindSafeMBeanServer from individual connector modules to
presto-common/util to eliminate code duplication across 5 connectors.
Copy link
Copy Markdown
Member

@hantangwangd hantangwangd left a comment

Choose a reason for hiding this comment

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

Thanks @KNagaVivek, lgtm!

@nishithakbhaskaran
Copy link
Copy Markdown
Contributor

Thanks @KNagaVivek .

@nishithakbhaskaran nishithakbhaskaran merged commit 4c8220e into prestodb:master Mar 4, 2026
111 of 112 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

from:IBM PR from IBM

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants