asereda-gs commented on PR #2698:
URL: https://github.com/apache/calcite/pull/2698#issuecomment-1092465865

   The problem is that `ElasticsearchSchemaFactory` (or other `SchemaFactory` 
implementations for that matter) creates new resource but it doesn't know 
exactly when to close it, only application does.
   
   Freeing resources on `finalize()` or cache timeout looks more like a hack.
   
   I believe there should be an explicit `close()` call from library user for 
`ElasticsearchSchemaFactory` to free its resources. 
   
   Maybe `Schema` or `SchemaFactory` should be implementing `AutoCloseable`. 
But closing event should be initiated explicitly by the application (not GC or 
cache expiration thread).
   
   So either application provides a `RestClient` and then it knows how to 
manage it or ask `ElasticsearchSchema` to close it. Unfortunately I don't see 
Calcite having `Schema.close` API.
   
   For example `JdbcSchema`  relies on external `javax.sql.DataSource`.
   
   Perhaps you can raise this question on the dev lists since I see similar 
issues with Mongo/Geode adapters.
   


-- 
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]

Reply via email to