yuqi1129 commented on code in PR #12349:
URL: https://github.com/apache/gravitino/pull/12349#discussion_r3709166183


##########
server-common/src/test/java/org/apache/gravitino/server/web/TestUtils.java:
##########
@@ -164,6 +165,19 @@ public void testAlreadyExistsWithThrowable() {
     assertEquals("New message", errorResponse.getMessage());
   }
 
+  @Test
+  public void testOptimisticLockConflict() {
+    OptimisticLockException exception = new 
OptimisticLockException("Conflict");
+    Response response = Utils.optimisticLockConflict("Conflict", exception);
+
+    assertNotNull(response);
+    assertEquals(Response.Status.CONFLICT.getStatusCode(), 
response.getStatus());
+    assertEquals(MediaType.APPLICATION_JSON, 
response.getMediaType().toString());
+    ErrorResponse errorResponse = (ErrorResponse) response.getEntity();
+    assertEquals(OptimisticLockException.class.getSimpleName(), 
errorResponse.getType());
+    assertEquals("Conflict", errorResponse.getMessage());
+  }

Review Comment:
   Added an assertion against ErrorConstants.OPTIMISTIC_LOCK_CONFLICT_CODE in 
TestUtils.



##########
api/src/main/java/org/apache/gravitino/exceptions/OptimisticLockException.java:
##########
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.gravitino.exceptions;
+
+import com.google.errorprone.annotations.FormatMethod;
+import com.google.errorprone.annotations.FormatString;
+
+/**
+ * Exception thrown when an optimistic-lock update fails because the entity 
changed after it was
+ * read.
+ */
+public class OptimisticLockException extends GravitinoRuntimeException {

Review Comment:
   Added private static final long serialVersionUID = 1L to 
OptimisticLockException.



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