Fix missing task failure error message on Overlord caused by MessageBodyWriter not found error on Middle Manager (#15412)

Fixes missing task failure error message on Overlord.

The error message was missing since TaskManagementResource#assignTask API wasn't annotated with @Produces(MediaType.APPLICATION_JSON) resulting in the response being treated as application/octet-stream, that in turn lead to MessageBodyWriter not found error on the middle manager. The exception is not logged on the middle manager itself since it happens even before entering the assignTask function -- while mapping arg Task -> MSQControllerTask.
This commit is contained in:
Vishesh Garg 2023-11-24 11:35:56 +05:30 committed by GitHub
parent 75d6993da9
commit 4ab0b71513
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 1 deletions

View File

@ -203,13 +203,19 @@ public class TaskManagementResource
@POST
@Path("/assignTask")
@Consumes({MediaType.APPLICATION_JSON, SmileMediaTypes.APPLICATION_JACKSON_SMILE})
@Produces({MediaType.APPLICATION_JSON, SmileMediaTypes.APPLICATION_JACKSON_SMILE})
public Response assignTask(Task task)
{
// Sometimes assignTask API can fail when the supplied task arg can't be interpreted due to some missing extension(s).
// In such cases, the call produces an error response without entering the function.
// @Produces helps to correctly write back this error response as JSON which otherwise ends up in an empty response
// message due to "MessageBodyWriter not found for SingletonImmutableBiMap" error.
// Ref: https://github.com/apache/druid/pull/15412.
try {
workerTaskManager.assignTask(task);
return Response.ok().build();
}
catch (RuntimeException ex) {
catch (Exception ex) {
return Response.serverError().entity(ex.getMessage()).build();
}
}