From 54068e8b1d6ddee5546424182b40ed9c161e8dae Mon Sep 17 00:00:00 2001 From: Charles Allen Date: Mon, 15 Dec 2014 15:24:59 -0800 Subject: [PATCH] Remove try-with-resources for log stream in WokerResource --- .../java/io/druid/indexing/overlord/RemoteTaskRunner.java | 2 -- .../java/io/druid/indexing/worker/http/WorkerResource.java | 7 ++++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/indexing-service/src/main/java/io/druid/indexing/overlord/RemoteTaskRunner.java b/indexing-service/src/main/java/io/druid/indexing/overlord/RemoteTaskRunner.java index 1497c7d93e0..355f018ea89 100644 --- a/indexing-service/src/main/java/io/druid/indexing/overlord/RemoteTaskRunner.java +++ b/indexing-service/src/main/java/io/druid/indexing/overlord/RemoteTaskRunner.java @@ -32,8 +32,6 @@ import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.io.ByteSource; -import com.google.common.io.ByteStreams; -import com.google.common.io.InputSupplier; import com.google.common.util.concurrent.FutureCallback; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; diff --git a/indexing-service/src/main/java/io/druid/indexing/worker/http/WorkerResource.java b/indexing-service/src/main/java/io/druid/indexing/worker/http/WorkerResource.java index dbecb5361c3..7992fd710c8 100644 --- a/indexing-service/src/main/java/io/druid/indexing/worker/http/WorkerResource.java +++ b/indexing-service/src/main/java/io/druid/indexing/worker/http/WorkerResource.java @@ -41,6 +41,7 @@ import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; +import java.io.IOException; import java.io.InputStream; /** @@ -167,10 +168,10 @@ public class WorkerResource final Optional stream = taskRunner.streamTaskLog(taskid, offset); if (stream.isPresent()) { - try (InputStream logStream = stream.get().openStream()) { - return Response.ok(logStream).build(); + try { + return Response.ok(stream.get().openStream()).build(); } - catch (Exception e) { + catch (IOException e) { log.warn(e, "Failed to read log for task: %s", taskid); return Response.serverError().build(); }