You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by GitBox <gi...@apache.org> on 2022/04/22 19:04:50 UTC
[GitHub] [druid] gianm commented on a diff in pull request #12006: RemoteTaskRunner: Fix NPE in streamTaskReports.
gianm commented on code in PR #12006:
URL: https://github.com/apache/druid/pull/12006#discussion_r856498881
##########
indexing-service/src/main/java/org/apache/druid/indexing/overlord/RemoteTaskRunner.java:
##########
@@ -652,37 +652,50 @@ public InputStream openStream() throws IOException
if (zkWorker == null) {
// Worker is not running this task, it might be available in deep storage
return Optional.absent();
- } else {
- TaskLocation taskLocation = runningTasks.get(taskId).getLocation();
- final URL url = TaskRunnerUtils.makeTaskLocationURL(
- taskLocation,
- "/druid/worker/v1/chat/%s/liveReports",
- taskId
- );
- return Optional.of(
- new ByteSource()
+ }
+
+ final RemoteTaskRunnerWorkItem runningWorkItem = runningTasks.get(taskId);
+
+ if (runningWorkItem == null) {
+ // Worker very recently exited.
+ return Optional.absent();
+ }
+
+ final TaskLocation taskLocation = runningWorkItem.getLocation();
+
+ if (TaskLocation.unknown().equals(taskLocation)) {
+ // No location known for this task. It may have not been assigned one yet.
+ return Optional.absent();
+ }
+
+ final URL url = TaskRunnerUtils.makeTaskLocationURL(
+ taskLocation,
+ "/druid/worker/v1/chat/%s/liveReports",
+ taskId
+ );
+ return Optional.of(
+ new ByteSource()
+ {
+ @Override
+ public InputStream openStream() throws IOException
{
- @Override
- public InputStream openStream() throws IOException
- {
- try {
- return httpClient.go(
- new Request(HttpMethod.GET, url),
- new InputStreamResponseHandler()
- ).get();
- }
- catch (InterruptedException e) {
- throw new RuntimeException(e);
- }
- catch (ExecutionException e) {
- // Unwrap if possible
- Throwables.propagateIfPossible(e.getCause(), IOException.class);
- throw new RuntimeException(e);
- }
+ try {
+ return httpClient.go(
+ new Request(HttpMethod.GET, url),
+ new InputStreamResponseHandler()
+ ).get();
+ }
+ catch (InterruptedException e) {
+ throw new RuntimeException(e);
+ }
+ catch (ExecutionException e) {
+ // Unwrap if possible
+ Throwables.propagateIfPossible(e.getCause(), IOException.class);
+ throw new RuntimeException(e);
Review Comment:
I'm not going to have a chance to come back to this any time soon. Is it OK if we merge this patch in the meantime?
--
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: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org