This is an automated email from the ASF dual-hosted git repository. kharekartik pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/pinot.git
The following commit(s) were added to refs/heads/master by this push: new c156042c75 Fix NPE in Minion (#13518) c156042c75 is described below commit c156042c755615838264e8455c3b84cece722e8b Author: aishikbh <ais...@startree.ai> AuthorDate: Tue Jul 2 17:57:02 2024 +0530 Fix NPE in Minion (#13518) * Fix NPE in Minion * Fix a corner case where tasks/schedule API is called without any table name or task name. * Put the null check before adding elements to the map. * address comments. * Added annotations. --- .../pinot/controller/api/resources/PinotTaskRestletResource.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotTaskRestletResource.java b/pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotTaskRestletResource.java index 2a83915354..1b5f8c2f95 100644 --- a/pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotTaskRestletResource.java +++ b/pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotTaskRestletResource.java @@ -616,8 +616,10 @@ public class PinotTaskRestletResource { @Produces(MediaType.APPLICATION_JSON) @Authenticate(AccessType.UPDATE) @ApiOperation("Schedule tasks and return a map from task type to task name scheduled") - public Map<String, String> scheduleTasks(@ApiParam(value = "Task type") @QueryParam("taskType") String taskType, - @ApiParam(value = "Table name (with type suffix)") @QueryParam("tableName") String tableName, + @Nullable + public Map<String, String> scheduleTasks( + @ApiParam(value = "Task type") @QueryParam("taskType") @Nullable String taskType, + @ApiParam(value = "Table name (with type suffix)") @QueryParam("tableName") @Nullable String tableName, @ApiParam(value = "Minion Instance tag to schedule the task explicitly on") @QueryParam("minionInstanceTag") @Nullable String minionInstanceTag, @Context HttpHeaders headers) { String database = headers != null ? headers.getHeaderString(DATABASE) : DEFAULT_DATABASE; @@ -632,8 +634,9 @@ public class PinotTaskRestletResource { Map<String, List<String>> allTaskNames = tableName != null ? _pinotTaskManager.scheduleAllTasksForTable( DatabaseUtils.translateTableName(tableName, headers), minionInstanceTag) : _pinotTaskManager.scheduleAllTasksForDatabase(database, minionInstanceTag); - return allTaskNames.entrySet().stream() + Map<String, String> result = allTaskNames.entrySet().stream().filter(entry -> entry.getValue() != null) .collect(Collectors.toMap(Map.Entry::getKey, entry -> String.join(",", entry.getValue()))); + return result.isEmpty() ? null : result; } } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org