Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation promotes questionable practices regarding resource closure #183

Closed
peter-gergely-horvath opened this issue Aug 13, 2018 · 2 comments
Assignees
Milestone

Comments

@peter-gergely-horvath
Copy link

peter-gergely-horvath commented Aug 13, 2018

  • Framework version: 1.1.4
  • Implementations: Jersey / Spring / Spring Boot

Scenario

The documentation shows the following approach as sample for creating a handler. Based on the description, if my understanding is correct the stream might not be closed properly, if an exception is thrown from handler.proxyStream :

@Override
public void handleRequest(InputStream inputStream, OutputStream outputStream, Context context)
        throws IOException {
    handler.proxyStream(inputStream, outputStream, context);

    // just in case it wasn't closed by the mapper
    outputStream.close();
}

The whole issue boils down to one question: who is in charge of the closing/handling of the lifecycle of the streams passed to a RequestStreamHandler? Is it the application code or the container? If it's the application's responsibility to close the steam, then you should probably show a more stable sample using a finally block or an ARM try block (and e.g. clarify why one does NOT have to close the input stream); if it is the container, then you should state that the application code does not have to deal with this issue and show a sample without closing the stream.

Expected behavior

Actual behavior

Steps to reproduce

Full log output

@sapessi
Copy link
Collaborator

sapessi commented Aug 13, 2018

Technically all Exceptions should be caught and handled here. The application code should not need to do anything with the stream. I'll fix the samples/archetypes to reflect this.

sapessi added a commit that referenced this issue Oct 22, 2018
…nged all samples and archetypes to remove the close() call for issue #183.
@sapessi sapessi added this to the Release 1.2 milestone Oct 22, 2018
@sapessi sapessi self-assigned this Oct 22, 2018
@sapessi
Copy link
Collaborator

sapessi commented Oct 22, 2018

This is ready for the next release. Closing this issue.

@sapessi sapessi closed this as completed Oct 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants