From: aaron-congo (@aaron-congo) <noreply+aaron-congo@github.com>
To: aws/aws-advanced-jdbc-wrapper <noreply+aws-aws-advanced-jdbc-wrapper@github.com>
Subject: Re: [aws/aws-advanced-jdbc-wrapper] PR #2237: feat: add efm3 host monitoring plugin with per-connection registration
Date: Wed, 18 Nov 2026 22:21:35 +0000
Message-ID: <gh-aws-aws-advanced-jdbc-wrapper-2237-rc4621666403@github.com> (raw)
In-Reply-To: <gh-aws-aws-advanced-jdbc-wrapper-2237@github.com>
References: <gh-aws-aws-advanced-jdbc-wrapper-2237@github.com>
(on wrapper/src/main/java/software/amazon/jdbc/plugin/efm/v3/HostMonitorServiceV3Impl.java)
nit: the monitor initializer lambda reads instance fields, so it captures `this`, and `MonitorServiceImpl.MonitorItem` keeps that supplier for as long as the monitor lives. That keeps the first connection's `HostMonitorServiceV3Impl`, its services container, its `PluginService`, and that connection reachable after the connection is dropped, which works against the weak references in `MonitoredConnectionSlot`. efm2 has the same pattern, but since efm3 is meant to be leak-resistant, copying the fields into locals would avoid it:
```suggestion
final Properties props = this.properties;
final int detectionTime = this.failureDetectionTimeMillis;
final int detectionInterval = this.failureDetectionIntervalMillis;
final int detectionCount = this.failureDetectionCount;
final long disposalTime = this.monitorDisposalTimeMillis;
final boolean abortIdle = this.abortIdleConnections;
final TelemetryCounter counter = this.abortedConnectionsCounter;
return this.coreMonitorService.runIfAbsent(
HostMonitorV3Impl.class,
key,
this.servicesContainer,
this.pluginService.getProperties(),
(monitorServicesContainer) -> new HostMonitorV3Impl(
monitorServicesContainer,
hostSpec,
props,
detectionTime,
detectionInterval,
detectionCount,
disposalTime,
abortIdle,
counter));
```