From d0f3db0f34b080d2fc79d24f7da6e2c8f352da30 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Fri, 15 Mar 2013 16:00:40 +1100 Subject: [PATCH] 401150 close input stream used from cached resource --- .../java/org/eclipse/jetty/http/HttpContent.java | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/jetty-http/src/main/java/org/eclipse/jetty/http/HttpContent.java b/jetty-http/src/main/java/org/eclipse/jetty/http/HttpContent.java index daead029f9b..4bc07053501 100644 --- a/jetty-http/src/main/java/org/eclipse/jetty/http/HttpContent.java +++ b/jetty-http/src/main/java/org/eclipse/jetty/http/HttpContent.java @@ -112,16 +112,14 @@ public interface HttpContent @Override public ByteBuffer getIndirectBuffer() { - try + if (_resource.length()<=0 || _maxBuffer<_resource.length()) + return null; + int length=(int)_resource.length(); + byte[] array = new byte[length]; + + int offset=0; + try (InputStream in=_resource.getInputStream()) { - if (_resource.length()<=0 || _maxBuffer<_resource.length()) - return null; - int length=(int)_resource.length(); - byte[] array = new byte[length]; - - int offset=0; - InputStream in=_resource.getInputStream(); - do { int filled=in.read(array,offset,length);