Remove try-with-resources for log stream in WokerResource

This commit is contained in:
Charles Allen 2014-12-15 15:24:59 -08:00
parent e872952390
commit 54068e8b1d
2 changed files with 4 additions and 5 deletions

View File

@ -32,8 +32,6 @@ import com.google.common.collect.Iterables;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.google.common.io.ByteSource; 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.FutureCallback;
import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListenableFuture;

View File

@ -41,6 +41,7 @@ import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam; import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
/** /**
@ -167,10 +168,10 @@ public class WorkerResource
final Optional<ByteSource> stream = taskRunner.streamTaskLog(taskid, offset); final Optional<ByteSource> stream = taskRunner.streamTaskLog(taskid, offset);
if (stream.isPresent()) { if (stream.isPresent()) {
try (InputStream logStream = stream.get().openStream()) { try {
return Response.ok(logStream).build(); return Response.ok(stream.get().openStream()).build();
} }
catch (Exception e) { catch (IOException e) {
log.warn(e, "Failed to read log for task: %s", taskid); log.warn(e, "Failed to read log for task: %s", taskid);
return Response.serverError().build(); return Response.serverError().build();
} }