Copilot commented on code in PR #4934:
URL: https://github.com/apache/polaris/pull/4934#discussion_r3496684314


##########
runtime/service/src/test/java/org/apache/polaris/service/catalog/iceberg/CommitTransactionEventTest.java:
##########
@@ -273,4 +278,81 @@ private CommitTransactionRequest 
generateCommitTransactionRequest(
                 updateRequirements,
                 List.of(new MetadataUpdate.SetProperties(Map.of(propertyName, 
"value2"))))));
   }
+
+  @Test
+  void testCommitTransactionCleansUpMetadataOnFailure(@TempDir Path tempDir) {
+    String location = tempDir.toAbsolutePath().toUri().toString();
+    if (location.endsWith("/")) {
+      location = location.substring(0, location.length() - 1);
+    }
+
+    // Create TestServices with a spy that will fail on 
updateEntitiesPropertiesIfNotChanged
+    // but only AFTER initial setup (table creation) succeeds.
+    AtomicBoolean shouldFail = new AtomicBoolean(false);
+    TestServices testServices =
+        TestServices.builder()
+            .config(
+                Map.of(
+                    "ALLOW_INSECURE_STORAGE_TYPES",
+                    "true",
+                    "SUPPORTED_CATALOG_STORAGE_TYPES",
+                    List.of("FILE")))
+            .metaStoreManagerDecorator(
+                msm -> {
+                  org.apache.polaris.core.persistence.PolarisMetaStoreManager 
spy =
+                      Mockito.spy(msm);
+                  Mockito.doAnswer(
+                          invocation -> {
+                            if (shouldFail.get()) {
+                              return new 
org.apache.polaris.core.persistence.dao.entity
+                                  .EntitiesResult(
+                                  
org.apache.polaris.core.persistence.dao.entity.BaseResult
+                                      .ReturnStatus.ENTITY_CANNOT_BE_RESOLVED,
+                                  "simulated CAS failure");

Review Comment:
   The `EntitiesResult` instantiation is split across tokens (`...dao.entity` 
on one line and `.EntitiesResult` on the next), which makes the code hard to 
read and is easy to mis-edit. Please reformat this into a normal constructor 
call (ideally also via imports, but at least keep the type name contiguous).



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