diff --git a/clients/client-java/src/test/java/org/apache/gravitino/client/integration/test/CatalogIT.java b/clients/client-java/src/test/java/org/apache/gravitino/client/integration/test/CatalogIT.java index 5360f9f7816..045c0ad694f 100644 --- a/clients/client-java/src/test/java/org/apache/gravitino/client/integration/test/CatalogIT.java +++ b/clients/client-java/src/test/java/org/apache/gravitino/client/integration/test/CatalogIT.java @@ -163,6 +163,7 @@ public void testCatalogAvailable() { catalogName, Catalog.Type.FILESET, "hadoop", "catalog comment", ImmutableMap.of()); Assertions.assertEquals("true", catalog.properties().get(PROPERTY_IN_USE)); + // test in-use and can't drop Exception exception = Assertions.assertThrows( CatalogInUseException.class, () -> metalake.dropCatalog(catalogName)); @@ -170,10 +171,16 @@ public void testCatalogAvailable() { exception.getMessage().contains("please disable it first or use force option"), exception.getMessage()); + // test disable and enable again Assertions.assertDoesNotThrow(() -> metalake.disableCatalog(catalogName)); Catalog loadedCatalog = metalake.loadCatalog(catalogName); Assertions.assertEquals("false", loadedCatalog.properties().get(PROPERTY_IN_USE)); + Assertions.assertDoesNotThrow(() -> metalake.enableCatalog(catalogName)); + loadedCatalog = metalake.loadCatalog(catalogName); + Assertions.assertEquals("true", loadedCatalog.properties().get(PROPERTY_IN_USE)); + + Assertions.assertDoesNotThrow(() -> metalake.disableCatalog(catalogName)); exception = Assertions.assertThrows( CatalogNotInUseException.class, diff --git a/core/src/main/java/org/apache/gravitino/catalog/CatalogManager.java b/core/src/main/java/org/apache/gravitino/catalog/CatalogManager.java index ed300e45c7e..959f91f5c9e 100644 --- a/core/src/main/java/org/apache/gravitino/catalog/CatalogManager.java +++ b/core/src/main/java/org/apache/gravitino/catalog/CatalogManager.java @@ -513,6 +513,8 @@ public void enableCatalog(NameIdentifier ident) return newCatalogBuilder.build(); }); + catalogCache.invalidate(ident); + } catch (IOException e) { throw new RuntimeException(e); }