11using System . Collections . Concurrent ;
22using System . Diagnostics ;
3- using System . Diagnostics . Metrics ;
43using System . Net ;
5- using System . Security . Authentication ;
64using Microsoft . Extensions . Logging ;
75using MySqlConnector . Logging ;
86using MySqlConnector . Protocol . Serialization ;
@@ -140,7 +138,7 @@ public async ValueTask<ServerSession> GetSessionAsync(MySqlConnection connection
140138 }
141139 }
142140
143- m_sessionSemaphore . Release ( ) ;
141+ _ = m_sessionSemaphore . Release ( ) ;
144142 throw ;
145143 }
146144 }
@@ -172,14 +170,14 @@ public async ValueTask ReturnAsync(IOBehavior ioBehavior, ServerSession session)
172170 try
173171 {
174172 lock ( m_leasedSessions )
175- m_leasedSessions . Remove ( session . Id ) ;
173+ _ = m_leasedSessions . Remove ( session . Id ) ;
176174 MetricsReporter . RemoveUsed ( this ) ;
177175 session . OwningConnection = null ;
178176 var sessionHealth = GetSessionHealth ( session ) ;
179177 if ( sessionHealth == 0 )
180178 {
181179 lock ( m_sessions )
182- m_sessions . AddFirst ( session ) ;
180+ _ = m_sessions . AddFirst ( session ) ;
183181 MetricsReporter . AddIdle ( this ) ;
184182 }
185183 else
@@ -194,15 +192,15 @@ public async ValueTask ReturnAsync(IOBehavior ioBehavior, ServerSession session)
194192 }
195193 finally
196194 {
197- m_sessionSemaphore . Release ( ) ;
195+ _ = m_sessionSemaphore . Release ( ) ;
198196 }
199197 }
200198
201199 public async Task ClearAsync ( IOBehavior ioBehavior , CancellationToken cancellationToken )
202200 {
203201 // increment the generation of the connection pool
204202 Log . ClearingConnectionPool ( m_logger , Id ) ;
205- Interlocked . Increment ( ref m_generation ) ;
203+ _ = Interlocked . Increment ( ref m_generation ) ;
206204 m_procedureCache = null ;
207205 await RecoverLeakedSessionsAsync ( ioBehavior ) . ConfigureAwait ( false ) ;
208206 await CleanPoolAsync ( ioBehavior , session => session . PoolGeneration != m_generation , false , cancellationToken ) . ConfigureAwait ( false ) ;
@@ -406,13 +404,13 @@ private async Task CreateMinimumPooledSessions(MySqlConnection connection, IOBeh
406404 var session = await ConnectSessionAsync ( connection , s_createdToReachMinimumPoolSize , Stopwatch . GetTimestamp ( ) , null , ioBehavior , cancellationToken ) . ConfigureAwait ( false ) ;
407405 AdjustHostConnectionCount ( session , 1 ) ;
408406 lock ( m_sessions )
409- m_sessions . AddFirst ( session ) ;
407+ _ = m_sessions . AddFirst ( session ) ;
410408 MetricsReporter . AddIdle ( this ) ;
411409 }
412410 finally
413411 {
414412 // connection is in pool; semaphore shouldn't be held any more
415- m_sessionSemaphore . Release ( ) ;
413+ _ = m_sessionSemaphore . Release ( ) ;
416414 }
417415 }
418416 }
@@ -452,7 +450,7 @@ private async ValueTask<ServerSession> ConnectSessionAsync(MySqlConnection conne
452450 var redirectedSession = new ServerSession ( m_connectionLogger , this , m_generation , Interlocked . Increment ( ref m_lastSessionId ) ) ;
453451 try
454452 {
455- await redirectedSession . ConnectAsync ( redirectedSettings , connection , startingTimestamp , m_loadBalancer , activity , ioBehavior , cancellationToken ) . ConfigureAwait ( false ) ;
453+ _ = await redirectedSession . ConnectAsync ( redirectedSettings , connection , startingTimestamp , m_loadBalancer , activity , ioBehavior , cancellationToken ) . ConfigureAwait ( false ) ;
456454 }
457455 catch ( Exception ex )
458456 {
@@ -614,7 +612,7 @@ private ConnectionPool(MySqlConnectorLoggingConfiguration loggingConfiguration,
614612 cs . HostNames ! . Count == 1 || cs . LoadBalance == MySqlLoadBalance . FailOver ? FailOverLoadBalancer . Instance :
615613 cs . LoadBalance == MySqlLoadBalance . Random ? RandomLoadBalancer . Instance :
616614 cs . LoadBalance == MySqlLoadBalance . LeastConnections ? new LeastConnectionsLoadBalancer ( m_hostSessions ! ) :
617- ( ILoadBalancer ) new RoundRobinLoadBalancer ( ) ;
615+ new RoundRobinLoadBalancer ( ) ;
618616
619617 // create tag lists for reporting pool metrics
620618 var connectionString = cs . ConnectionStringBuilder . GetConnectionString ( includePassword : false ) ;
@@ -812,7 +810,7 @@ private static void OnAppDomainShutDown(object? sender, EventArgs e) =>
812810 ClearPoolsAsync ( IOBehavior . Synchronous , CancellationToken . None ) . GetAwaiter ( ) . GetResult ( ) ;
813811
814812 private static readonly ConcurrentDictionary < string , ConnectionPool ? > s_pools = new ( ) ;
815- private static readonly List < ConnectionPool > s_allPools = new ( ) ;
813+ private static readonly List < ConnectionPool > s_allPools = [ ] ;
816814 private static readonly Action < ILogger , int , string , Exception ? > s_createdNewSession = LoggerMessage . Define < int , string > (
817815 LogLevel . Debug , new EventId ( EventIds . PoolCreatedNewSession , nameof ( EventIds . PoolCreatedNewSession ) ) ,
818816 "Pool {PoolId} has no pooled session available; created new session {SessionId}" ) ;
0 commit comments