flyrain commented on code in PR #3281:
URL: https://github.com/apache/polaris/pull/3281#discussion_r2629297931
##########
persistence/relational-jdbc/src/main/java/org/apache/polaris/persistence/relational/jdbc/JdbcMetaStoreManagerFactory.java:
##########
@@ -196,15 +196,20 @@ public Map<String, BaseResult>
purgeRealms(Iterable<String> realms) {
for (String realm : realms) {
RealmContext realmContext = () -> realm;
- PolarisMetaStoreManager metaStoreManager =
getOrCreateMetaStoreManager(realmContext);
- BasePersistence session = getOrCreateSession(realmContext);
-
- PolarisCallContext callContext = new PolarisCallContext(realmContext,
session);
- BaseResult result = metaStoreManager.purge(callContext);
- results.put(realm, result);
-
- sessionSupplierMap.remove(realm);
- metaStoreManagerMap.remove(realm);
+ try {
+ PolarisMetaStoreManager metaStoreManager =
getOrCreateMetaStoreManager(realmContext);
+ BasePersistence session = getOrCreateSession(realmContext);
+
+ PolarisCallContext callContext = new PolarisCallContext(realmContext,
session);
+ BaseResult result = metaStoreManager.purge(callContext);
+ results.put(realm, result);
+
+ sessionSupplierMap.remove(realm);
+ metaStoreManagerMap.remove(realm);
+ } catch (IllegalStateException e) {
+ // Realm is not bootstrapped, return a failed result
+ results.put(realm, new
BaseResult(BaseResult.ReturnStatus.ENTITY_NOT_FOUND, e.getMessage()));
Review Comment:
To fix
```
RelationalJdbcPurgeCommandTest > testPurgeFailure(LaunchResult) FAILED
org.assertj.core.error.AssertJMultipleFailuresError at
PurgeCommandTestBase.java:48
```
This is needed as `runtime-defaults` has configuration file
`application.properties` with Quarkus configuration like logging, console, or
output-related settings, which interferes with how Quarkus Main tests capture
stdout. When the exception is thrown, the output isn't captured in
`LaunchResult.getOutput()`. It only goes to logs. This causes the test
assertion to fail because `result.getOutput()` is empty.
The fix ensures that when a realm isn't bootstrapped, the `PurgeCommand`
receives a failed BaseResult and can properly write the error message to
stdout,
https://github.com/apache/polaris/blob/dc4e3439042be2d305b4ba945309653512f0dc3a/runtime/admin/src/main/java/org/apache/polaris/admintool/PurgeCommand.java#L53,
instead of catching an exception and only writing to stderr (line 62).
--
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]