java - How to close a Stream of a REST Service? -


i need make java rest service return inputstream response. problem don't know how close stream after client receives entire stream. i'm using java , cxf. thanks

@get @path("/{uuid}") @produces(mediatype.application_octet_stream) public response getattachmentbyuuid(@pathparam("uuid")string uuid) {  //getting inputstream aws s3  inpputsream is=getstreamfroms3(uuid);  return response.status(response.status.ok).entity(is).build();  // "is" stream causes memory leak,, have close it. client side not controlled me } 

jax-rs implemented using java servlets. in case of cxf used cxfservlet. stream sent client using httpservletresponse of servlet interface

public void doget(httpservletrequest request, httpservletresponse response) 

you should not close stream source (httpservletresponse) if have not created it. responsability of container, , can interfere life cycle of request

see is necessary close input stream returned httpservletrequest?


Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -