pjfanning opened a new pull request, #1877:
URL: https://github.com/apache/pekko-connectors/pull/1877

   **Motivation:**
   
   `PravegaTableReadFlow` and `PravegaTableSource` cleaned up with:
   
   ```scala
   override def postStop(): Unit = {
     log.debug("Closing table {}", tableName)
     table.close()
     keyValueTableFactory.close()
   }
   ```
   
   `preStart` creates the factory first and the table from it:
   
   ```scala
   keyValueTableFactory = KeyValueTableFactory.withScope(scope, 
tableSettings.clientConfig)
   table = keyValueTableFactory.forKeyValueTable(tableName, kvtClientConfig)
   ```
   
   If `forKeyValueTable` throws — wrong table name or scope, auth failure: all 
ordinary production misconfigurations — the factory is open and holds a 
connection pool (Netty channels to the segment store) while `table` is still 
`null`. `postStop` then throws a `NullPointerException` on `table.close()` and 
**never reaches** `keyValueTableFactory.close()`, so the pool leaks.
   
   `PravegaTableWriteFlow` already wrapped the table close in `Try`, so its 
factory was released — but it still logged a spurious NPE for a table that was 
never opened.
   
   **Modification:**
   
   Guard both closes with a null check and close each independently, so a 
failure to close the table cannot prevent the factory close. Failures are 
logged rather than rethrown, matching `PravegaSource.postStop`: the stage has 
already stopped, so failing here would only mask why it stopped.
   
   The three copies of this sequence are extracted to 
`PravegaTableCleanup.closeTableAndFactory`, which also makes the ordering 
testable without a Pravega cluster.
   
   **Result:**
   
   The connection pool is released even when `preStart` fails between creating 
the factory and the table.
   
   **Tests:**
   
   Added `PravegaTableCleanupSpec` covering the ordinary path, a table that 
fails to close, a table that was never opened, and both failing.
   
   It needs no Pravega server — which matters here, because this path is 
reached only when `preStart` fails partway, so the Docker-based integration 
tests never exercise it.
   
   4 tests pass. Ran `pravega/mimaReportBinaryIssues` (clean) and the module 
scalafmt checks.
   
   **References:**
   
   Compare `PravegaSource.postStop`, which guards each close.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to