This is an automated email from the ASF dual-hosted git repository.
czy006 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/amoro.git
The following commit(s) were added to refs/heads/master by this push:
new 2c64571f9 [AMORO-4361][ams] Fix Iceberg REST catalog table creation
collision to return 409 Conflict (#4362)
2c64571f9 is described below
commit 2c64571f99b6ea41fc2f214612dc34100ebb780d
Author: Aakash <[email protected]>
AuthorDate: Mon Sep 7 08:38:35 2026 +0530
[AMORO-4361][ams] Fix Iceberg REST catalog table creation collision to
return 409 Conflict (#4362)
* [AMORO-4361][ams] Fix Iceberg REST catalog table creation collision to
return 409 Conflict
* [AMORO-4361][ams] Address review comments: trim upfront checks and map
exception codes
---
.../java/org/apache/amoro/server/RestCatalogService.java | 5 ++++-
.../org/apache/amoro/server/TestRestCatalogService.java | 14 ++++++++++++++
2 files changed, 18 insertions(+), 1 deletion(-)
diff --git
a/amoro-ams/src/main/java/org/apache/amoro/server/RestCatalogService.java
b/amoro-ams/src/main/java/org/apache/amoro/server/RestCatalogService.java
index c13ed4013..4769c5b2c 100644
--- a/amoro-ams/src/main/java/org/apache/amoro/server/RestCatalogService.java
+++ b/amoro-ams/src/main/java/org/apache/amoro/server/RestCatalogService.java
@@ -636,8 +636,11 @@ public class RestCatalogService extends PersistentBase
implements RestExtension
return NotFound;
} else if (e instanceof NoSuchNamespaceException) {
return NotFound;
- } else if (e instanceof AlreadyExistsException) {
+ } else if (e instanceof AlreadyExistsException
+ || e instanceof org.apache.amoro.exception.AlreadyExistsException) {
return Conflict;
+ } else if (e instanceof org.apache.amoro.exception.ForbiddenException) {
+ return Forbidden;
}
return InternalServerError;
}
diff --git
a/amoro-ams/src/test/java/org/apache/amoro/server/TestRestCatalogService.java
b/amoro-ams/src/test/java/org/apache/amoro/server/TestRestCatalogService.java
index 26c39dc41..a66925bd6 100644
---
a/amoro-ams/src/test/java/org/apache/amoro/server/TestRestCatalogService.java
+++
b/amoro-ams/src/test/java/org/apache/amoro/server/TestRestCatalogService.java
@@ -18,6 +18,8 @@
package org.apache.amoro.server;
+import org.apache.amoro.exception.AlreadyExistsException;
+import org.apache.amoro.exception.ForbiddenException;
import org.apache.iceberg.exceptions.BadRequestException;
import org.apache.iceberg.exceptions.UnprocessableEntityException;
import org.junit.jupiter.api.Assertions;
@@ -39,5 +41,17 @@ public class TestRestCatalogService {
RestCatalogService.IcebergRestErrorCode.UnprocessableEntity,
RestCatalogService.IcebergRestErrorCode.exceptionToCode(
new UnprocessableEntityException("conflicting property changes")));
+ Assertions.assertEquals(
+ RestCatalogService.IcebergRestErrorCode.Conflict,
+ RestCatalogService.IcebergRestErrorCode.exceptionToCode(
+ new org.apache.iceberg.exceptions.AlreadyExistsException("table
already exists")));
+ Assertions.assertEquals(
+ RestCatalogService.IcebergRestErrorCode.Conflict,
+ RestCatalogService.IcebergRestErrorCode.exceptionToCode(
+ new AlreadyExistsException("table already exists")));
+ Assertions.assertEquals(
+ RestCatalogService.IcebergRestErrorCode.Forbidden,
+ RestCatalogService.IcebergRestErrorCode.exceptionToCode(
+ new ForbiddenException("forbidden")));
}
}