This is an automated email from the ASF dual-hosted git repository.

aplex pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/gobblin.git


The following commit(s) were added to refs/heads/master by this push:
     new ed68f6c  [GOBBLIN-1545] Wrap RestLiServiceException inside a 
CreateKVResponse (#3395)
ed68f6c is described below

commit ed68f6cd16c77b246e119bf530ab0432baf9f4ca
Author: Arjun Singh Bora <[email protected]>
AuthorDate: Thu Sep 16 10:46:19 2021 -0700

    [GOBBLIN-1545] Wrap RestLiServiceException inside a CreateKVResponse (#3395)
    
    Throwing exception in the service logs may confuse users (or log parsing 
scripts) that there is some issue with the service that requires attention. So 
we should not throw exception when it is a bad request and no issue from the 
service side. In these cases, we should wrap the exception in a Restli response 
that the caller can open.
---
 .../apache/gobblin/service/FlowConfigV2ResourceLocalHandler.java  | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git 
a/gobblin-restli/gobblin-flow-config-service/gobblin-flow-config-service-server/src/main/java/org/apache/gobblin/service/FlowConfigV2ResourceLocalHandler.java
 
b/gobblin-restli/gobblin-flow-config-service/gobblin-flow-config-service-server/src/main/java/org/apache/gobblin/service/FlowConfigV2ResourceLocalHandler.java
index 70d82d5..3c64e47 100644
--- 
a/gobblin-restli/gobblin-flow-config-service/gobblin-flow-config-service-server/src/main/java/org/apache/gobblin/service/FlowConfigV2ResourceLocalHandler.java
+++ 
b/gobblin-restli/gobblin-flow-config-service/gobblin-flow-config-service-server/src/main/java/org/apache/gobblin/service/FlowConfigV2ResourceLocalHandler.java
@@ -70,8 +70,8 @@ public class FlowConfigV2ResourceLocalHandler extends 
FlowConfigResourceLocalHan
     // Return conflict and take no action if flowSpec has already been created
     if (this.flowCatalog.exists(flowSpec.getUri())) {
       log.warn("FlowSpec with URI {} already exists, no action will be taken", 
flowSpec.getUri());
-      throw new RestLiServiceException(HttpStatus.S_409_CONFLICT,
-          "FlowSpec with URI " + flowSpec.getUri() + " already exists, no 
action will be taken");
+      return new CreateKVResponse<>(new 
RestLiServiceException(HttpStatus.S_409_CONFLICT,
+          "FlowSpec with URI " + flowSpec.getUri() + " already exists, no 
action will be taken"));
     }
 
     Map<String, AddSpecResponse> responseMap = this.flowCatalog.put(flowSpec, 
triggerListener);
@@ -93,10 +93,10 @@ public class FlowConfigV2ResourceLocalHandler extends 
FlowConfigResourceLocalHan
       if (!flowSpec.getCompilationErrors().isEmpty()) {
         message = message + " Compilation errors encountered: " + 
flowSpec.getCompilationErrors();
       }
-      throw new RestLiServiceException(HttpStatus.S_400_BAD_REQUEST, message);
+      return new CreateKVResponse<>(new 
RestLiServiceException(HttpStatus.S_400_BAD_REQUEST, message));
     }
 
-    return new CreateKVResponse(new ComplexResourceKey<>(flowConfig.getId(), 
flowStatusId), flowConfig, httpStatus);
+    return new CreateKVResponse<>(new ComplexResourceKey<>(flowConfig.getId(), 
flowStatusId), flowConfig, httpStatus);
   }
 
   /**

Reply via email to