jackjlli commented on code in PR #8784:
URL: https://github.com/apache/pinot/pull/8784#discussion_r883162179


##########
pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotSegmentUploadDownloadRestletResource.java:
##########
@@ -589,20 +589,19 @@ public Response startReplaceSegments(
       @ApiParam(value = "Force cleanup") @QueryParam("forceCleanup") 
@DefaultValue("false") boolean forceCleanup,
       @ApiParam(value = "Fields belonging to start replace segment request", 
required = true)
           StartReplaceSegmentsRequest startReplaceSegmentsRequest) {
+    TableType tableType = Constants.validateTableType(tableTypeStr);
+    if (tableType == null) {
+      throw new ControllerApplicationException(LOGGER, "Table type should 
either be offline or realtime",
+          Response.Status.BAD_REQUEST);
+    }
+    String tableNameWithType =
+        
ResourceUtils.getExistingTableNamesWithType(_pinotHelixResourceManager, 
tableName, tableType, LOGGER).get(0);
     try {
-      TableType tableType = Constants.validateTableType(tableTypeStr);
-      if (tableType == null) {
-        throw new ControllerApplicationException(LOGGER, "Table type should 
either be offline or realtime",
-            Response.Status.BAD_REQUEST);
-      }
-      String tableNameWithType =
-          
ResourceUtils.getExistingTableNamesWithType(_pinotHelixResourceManager, 
tableName, tableType, LOGGER).get(0);
       String segmentLineageEntryId = 
_pinotHelixResourceManager.startReplaceSegments(tableNameWithType,
           startReplaceSegmentsRequest.getSegmentsFrom(), 
startReplaceSegmentsRequest.getSegmentsTo(), forceCleanup);
       return 
Response.ok(JsonUtils.newObjectNode().put("segmentLineageEntryId", 
segmentLineageEntryId)).build();
-    } catch (WebApplicationException wae) {

Review Comment:
   After emitting the metric, you can add one more check to check if the 
exception is an instance of `WebApplicationException`. If so, you don't need to 
wrap with a `ControllerApplicationException` again. By doing so, the logic 
should be the same as the current logic.



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to