Commit e8411bc797e85ce9147b2ebe4fcc0008ee73ded0

Authored by 648540858
1 parent b9a33f03

修复截图截图未关闭流 #1087

src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceQuery.java
@@ -36,6 +36,7 @@ import org.springframework.util.ObjectUtils; @@ -36,6 +36,7 @@ import org.springframework.util.ObjectUtils;
36 import org.springframework.web.bind.annotation.*; 36 import org.springframework.web.bind.annotation.*;
37 import org.springframework.web.context.request.async.DeferredResult; 37 import org.springframework.web.context.request.async.DeferredResult;
38 38
  39 +import javax.servlet.ServletOutputStream;
39 import javax.servlet.http.HttpServletResponse; 40 import javax.servlet.http.HttpServletResponse;
40 import javax.sip.InvalidArgumentException; 41 import javax.sip.InvalidArgumentException;
41 import javax.sip.SipException; 42 import javax.sip.SipException;
@@ -472,7 +473,10 @@ public class DeviceQuery { @@ -472,7 +473,10 @@ public class DeviceQuery {
472 try { 473 try {
473 final InputStream in = Files.newInputStream(new File("snap" + File.separator + deviceId + "_" + channelId + (mark == null? ".jpg": ("_" + mark + ".jpg"))).toPath()); 474 final InputStream in = Files.newInputStream(new File("snap" + File.separator + deviceId + "_" + channelId + (mark == null? ".jpg": ("_" + mark + ".jpg"))).toPath());
474 resp.setContentType(MediaType.IMAGE_PNG_VALUE); 475 resp.setContentType(MediaType.IMAGE_PNG_VALUE);
  476 + ServletOutputStream outputStream = resp.getOutputStream();
475 IOUtils.copy(in, resp.getOutputStream()); 477 IOUtils.copy(in, resp.getOutputStream());
  478 + in.close();
  479 + outputStream.close();
476 } catch (IOException e) { 480 } catch (IOException e) {
477 resp.setStatus(HttpServletResponse.SC_NOT_FOUND); 481 resp.setStatus(HttpServletResponse.SC_NOT_FOUND);
478 } 482 }