Skip to content

Conversation

@Akanksha-kedia
Copy link
Contributor

Description

. ClusterStatsJdbcMonitor.java - Complete Immutable Configuration Refactor

Problem: Mutable Properties field causing potential thread safety issues Solution: Created comprehensive immutable configuration system

New Files Created:

  • JdbcMonitorConfiguration.java - Immutable JDBC configuration class with factory methods

Key Changes:

  • ✅ Replaced private final Properties properties with private final JdbcMonitorConfiguration jdbcConfig
  • ✅ Added factory method JdbcMonitorConfiguration.from() for easy construction
  • ✅ Added toProperties() method for backward compatibility with JDBC drivers
  • ✅ Improved error handling with fail-fast validation
  • ✅ Enhanced SSL configuration based on URL protocol
  • ✅ Better resource management and exception handling

2. GatewayWebAppResource.java - Immutable UI Configuration

Problem: Mutable UIConfiguration field in web resource Solution: Created immutable wrapper with defensive copying

New Files Created:

  • ImmutableUIConfiguration.java - Thread-safe UI configuration wrapper

Key Changes:

  • ✅ Replaced private final UIConfiguration uiConfiguration with private final ImmutableUIConfiguration immutableUiConfiguration
  • ✅ Added ImmutableUIConfiguration.copyOf() factory method
  • ✅ Defensive copying in constructor to prevent external modification
  • ✅ Maintained API compatibility while ensuring thread safety
  • ✅ Used Guava's ImmutableList for collections

Additional context and related issues

Release notes

( ) This is not user-visible or is docs only, and no release notes are required.
( ) Release notes are required, with the following suggested text:

* Fix some things.

this.routingRulesManager = requireNonNull(routingRulesManager, "routingRulesManager is null");

// Create immutable copy of UI configuration to ensure thread safety
this.immutableUiConfiguration = ImmutableUIConfiguration.copyOf(configuration.getUiConfiguration());
Copy link
Member

Choose a reason for hiding this comment

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

I don’t understand the reasoning behind this change.
If UiConfiguration does not change throughout the application’s lifetime, there is no need to copy it, and we won’t have a thread safety problem.
If UiConfiguration can change, this will result in a stale copy.

@Akanksha-kedia Akanksha-kedia force-pushed the feature/todo1 branch 2 times, most recently from af6555e to fc1f627 Compare October 6, 2025 10:07
@oneonestar
Copy link
Member

Replaced by #777

@oneonestar oneonestar closed this Oct 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

2 participants