abhishekrb19 commented on code in PR #16206:
URL: https://github.com/apache/druid/pull/16206#discussion_r1539937267


##########
server/src/main/java/org/apache/druid/server/http/MetadataResource.java:
##########
@@ -349,37 +353,52 @@ public Response getUnusedSegmentsInDataSource(
       @QueryParam("sortOrder") @Nullable final String sortOrder
   )
   {
-    if (dataSource == null || dataSource.isEmpty()) {
-      throw InvalidInput.exception("dataSourceName must be non-empty");
-    }
-    if (limit != null && limit < 0) {
-      throw InvalidInput.exception("Invalid limit[%s] specified. Limit must be 
> 0", limit);
-    }
+    try {
+      if (dataSource == null || dataSource.isEmpty()) {
+        throw InvalidInput.exception("dataSourceName must be non-empty.");
+      }
 
-    if (lastSegmentId != null && SegmentId.tryParse(dataSource, lastSegmentId) 
== null) {
-      throw InvalidInput.exception("Invalid lastSegmentId[%s] specified.", 
lastSegmentId);
-    }
+      if (limit != null && limit < 0) {
+        throw InvalidInput.exception("Invalid limit[%s] specified. Limit must 
be > 0.", limit);
+      }
 
-    SortOrder theSortOrder = sortOrder == null ? null : 
SortOrder.fromValue(sortOrder);
+      if (lastSegmentId != null && SegmentId.tryParse(dataSource, 
lastSegmentId) == null) {
+        throw InvalidInput.exception("Invalid lastSegmentId[%s] specified.", 
lastSegmentId);
+      }
 
-    final Interval theInterval = interval != null ? 
Intervals.of(interval.replace('_', '/')) : null;
-    Iterable<DataSegmentPlus> unusedSegments = 
segmentsMetadataManager.iterateAllUnusedSegmentsForDatasource(
-        dataSource,
-        theInterval,
-        limit,
-        lastSegmentId,
-        theSortOrder
-    );
+      final SortOrder theSortOrder = sortOrder == null ? null : 
SortOrder.fromValue(sortOrder);
+
+      final Interval theInterval = interval != null ? 
Intervals.of(interval.replace('_', '/')) : null;
+      final Iterable<DataSegmentPlus> unusedSegments = 
segmentsMetadataManager.iterateAllUnusedSegmentsForDatasource(
+          dataSource,
+          theInterval,
+          limit,
+          lastSegmentId,
+          theSortOrder
+      );
 
-    final Function<DataSegmentPlus, Iterable<ResourceAction>> raGenerator = 
segment -> Collections.singletonList(
-        
AuthorizationUtils.DATASOURCE_READ_RA_GENERATOR.apply(segment.getDataSegment().getDataSource()));
+      final Function<DataSegmentPlus, Iterable<ResourceAction>> raGenerator = 
segment -> Collections.singletonList(
+          
AuthorizationUtils.DATASOURCE_READ_RA_GENERATOR.apply(segment.getDataSegment().getDataSource()));
 
-    final Iterable<DataSegmentPlus> authorizedSegments =
-        AuthorizationUtils.filterAuthorizedResources(req, unusedSegments, 
raGenerator, authorizerMapper);
+      final Iterable<DataSegmentPlus> authorizedSegments =
+          AuthorizationUtils.filterAuthorizedResources(req, unusedSegments, 
raGenerator, authorizerMapper);
 
-    final List<DataSegmentPlus> retVal = new ArrayList<>();
-    authorizedSegments.iterator().forEachRemaining(retVal::add);
-    return Response.status(Response.Status.OK).entity(retVal).build();
+      final List<DataSegmentPlus> retVal = new ArrayList<>();
+      authorizedSegments.iterator().forEachRemaining(retVal::add);
+      return Response.status(Response.Status.OK).entity(retVal).build();
+    }
+    catch (DruidException e) {

Review Comment:
   Yes, I agree and had similar thoughts in this comment: 
https://github.com/apache/druid/pull/16206#discussion_r1539600493



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