kbendick commented on code in PR #4495:
URL: https://github.com/apache/iceberg/pull/4495#discussion_r845424567


##########
core/src/test/java/org/apache/iceberg/rest/TestRESTCatalog.java:
##########
@@ -42,20 +50,29 @@ public void createCatalog() {
     File warehouse = temp.toFile();
     Configuration conf = new Configuration();
 
-    JdbcCatalog backendCatalog = new JdbcCatalog();
-    backendCatalog.setConf(conf);
-    Map<String, String> backendCatalogProperties = ImmutableMap.of(
-        CatalogProperties.WAREHOUSE_LOCATION, warehouse.getAbsolutePath(),
-        CatalogProperties.URI, "jdbc:sqlite:file::memory:?ic" + 
UUID.randomUUID().toString().replace("-", ""),
-        JdbcCatalog.PROPERTY_PREFIX + "username", "user",
-        JdbcCatalog.PROPERTY_PREFIX + "password", "password");
-    backendCatalog.initialize("backend", backendCatalogProperties);
+    this.restCatalog = new RESTCatalog((config) -> {
+      JdbcCatalog backendCatalog = new JdbcCatalog();
+      backendCatalog.setConf(conf);
+      Map<String, String> backendCatalogProperties = ImmutableMap.of(
+          CatalogProperties.WAREHOUSE_LOCATION, warehouse.getAbsolutePath(),
+          CatalogProperties.URI, "jdbc:sqlite:file::memory:?ic" + 
UUID.randomUUID().toString().replace("-", ""),
+          JdbcCatalog.PROPERTY_PREFIX + "username", "user",
+          JdbcCatalog.PROPERTY_PREFIX + "password", "password");

Review Comment:
   The `backendCatalog` creation needed to be moved into the constructor so 
that the single use connection that is opened and then closed to fetch the 
server config doesn't permanently close the underlying JDBC catalog connection.
   
   This way, the lifecycle of the connection to the JDBC catalog mirrors that 
of the HTTP client.



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