File upload endpoint need to close InputStream?
问题 @POST @Consumes(MediaType.MULTIPART_FORM_DATA) @Path("/upload") public String upload(@FormDataParam("file") InputStream inputStream) { ... inputStream.close(); // necessary? } For an API endpoint that accepts a file input, do we need to manually close the InputStream or does the framework do it for us? I have checked the Jersey docs but could not find any information about it. Looking for credible source or some way to validate it. 回答1: It is your responsibility to close InputStream. Jersey