jax-rs-spec
  1. jax-rs-spec
  2. JAX_RS_SPEC-424

Auto-closing InputStream in Response.readEntity can break the client code reading DOM Document or JAXP Source

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 2.0
    • Fix Version/s: 2.1
    • Component/s: model api
    • Labels:
      None

      Description

      Hi, after we implemented an auto-closing of InputStream in Response.readEntity we started seeing random failures. For example, CXF tests where we had Response.readEntity(StreamSource.class) was passing OK on two branches but was failing on the 3rd one. One DOM-based tests started failing as well.
      Took a bit of time to figure out it was to do with closing the stream too early in those cases.

      Proposal: either completely disallow the auto-closing of InputStream or make it conditional (example, based on some property, etc)

        Activity

        Hide
        zhengxb added a comment -

        [~Marek] Is there any decision on this?

        We are using CXF 2.7.5 and thinking if it is right way to migrate to CXF 2.7.7 to pick up the implementation of auto-closing of InputStream, in order to make our CXF proxy re-use connections.

        Show
        zhengxb added a comment - [~Marek] Is there any decision on this? We are using CXF 2.7.5 and thinking if it is right way to migrate to CXF 2.7.7 to pick up the implementation of auto-closing of InputStream, in order to make our CXF proxy re-use connections.
        Hide
        beryozkin_sergey added a comment - - edited

        Note this is not a CXF specific forum. The discussion needs to be specific about the pros and cons of the auto-closing approach without referring to CXF.
        As I've described, we have a number of real-case issues caused by the automatic IO close. Example, we have a case of a DOM and DOM4J Document being returned from Response.readEntity in our internal code. Auto closing is problematic in such cases.

        Show
        beryozkin_sergey added a comment - - edited Note this is not a CXF specific forum. The discussion needs to be specific about the pros and cons of the auto-closing approach without referring to CXF. As I've described, we have a number of real-case issues caused by the automatic IO close. Example, we have a case of a DOM and DOM4J Document being returned from Response.readEntity in our internal code. Auto closing is problematic in such cases.
        Hide
        beryozkin_sergey added a comment -

        Hi Marek -
        We have yet another issue created against CXF not auto-closing by default for non-InputStream classes.
        As I've already described above doing so by default caused a fair bit of pain for us (in the actual production code). I think having a property or some more restrictions (example, update the docs to refer to JAXP Source, DOM Document and possibly few other cases) should be done
        IMHO this issue should be prioritized for 2.1
        Thanks

        Show
        beryozkin_sergey added a comment - Hi Marek - We have yet another issue created against CXF not auto-closing by default for non-InputStream classes. As I've already described above doing so by default caused a fair bit of pain for us (in the actual production code). I think having a property or some more restrictions (example, update the docs to refer to JAXP Source, DOM Document and possibly few other cases) should be done IMHO this issue should be prioritized for 2.1 Thanks

          People

          • Assignee:
            Marek Potociar
            Reporter:
            beryozkin_sergey
          • Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated: