Skip to content

Reconsider calling close() of the previous assigned stream or channel in MessageBuffer(Input|Output)#reset #173

Description

@komamitsu

In #169 and #170, we made some changes to call a previously assigned stream or channel instead of a new one passed as a parameter.

But I found https://github.com/spring-projects/spring-framework does the followings when it returns a HTTP request with jackson-dataformat-msgpack.

  • Reuses an OutputStream (org.apache.catalina.connector.CoyoteOutputStream) without having called its close()
    • Of course, it includes a new SocketChannel each time
  • Creates a new org.msgpack.jackson.dataformat.MessagePackGenerator
    • Which calls org.msgpack.core.buffer.OutputStreamBufferOutput#reset internally except for the first time

As a result, the OutputStream the framework tries to reuse will be closed unexpectedly and MessagePack fails to write data to it.

Also, on second thought, I think MessageBuffer(Input|Output)#reset shouldn't close the previous output or channel for the following reasons.

  • Closing the previous output or channel in the methods is unexpected behaviour for the user and we can't know what it causes (it depends on their implementation)
  • Releasing those resources are basically the user's responsibility

Also, on second thought, it sounds MessageBuffer(Input|Output)#reset shouldn't close the previous output or channel for the following reasons.

@xerial What do you think? If the above ideas sound good, I can fix this issue easily.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions