jersey
  1. jersey
  2. JERSEY-1984

HttpUrlConnector: connect timeout is doubled

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.1
    • Fix Version/s: 2.6
    • Component/s: connectors
    • Labels:
      None

      Description

      If you create a Client that uses HttpUrlConnector with ClientProperties.CONNECT_TIMEOUT set, then try to send a request that includes an entity, the actual timeout will be double the configured value.

      This appears to happen because workers.writeTo() in ClientRequest.writeEntity() uses the configured timeout, and an exception is thrown, but then commitStream() in the finally block seems to attempt to connect again using the same timeout.

      This issue can be worked around by using a different Connector, such as the ApacheConnector.

        Issue Links

          Activity

          Hide
          Jakub Podlesak added a comment -

          Added a reproducing unit test (awaiting review)
          There is a known workaround, moving to 2.0-backlog.

          Show
          Jakub Podlesak added a comment - Added a reproducing unit test (awaiting review) There is a known workaround, moving to 2.0-backlog.
          Hide
          Marek Potociar added a comment -

          The new reproducer unit test in core-client/src/test/java/org/glassfish/jersey/client/HttpUrlConnectorTest.java needs to be un-ignored as part of the fix.

          Show
          Marek Potociar added a comment - The new reproducer unit test in core-client/src/test/java/org/glassfish/jersey/client/HttpUrlConnectorTest.java needs to be un-ignored as part of the fix.
          Hide
          Marek Potociar added a comment - - edited

          MAY be related to JERSEY-2176

          Show
          Marek Potociar added a comment - - edited MAY be related to JERSEY-2176
          Hide
          Libor Kramolis added a comment -

          Connection timeout is platform specific. I had to lower timeout value in mentioned tests. And also have to use read timeout because connection did not timeouted.

          Still not clear how this should be fixed. What would you prefer?
          1) Reset connection timeout before commitStream() call - it can prolong it more, default timeout is/may be higher.
          2) Set really small connect/read timeouts before commitStream() call - what is small value? It can not be so small because it could interrupt too quickly.

          Show
          Libor Kramolis added a comment - Connection timeout is platform specific. I had to lower timeout value in mentioned tests. And also have to use read timeout because connection did not timeouted. Still not clear how this should be fixed. What would you prefer? 1) Reset connection timeout before commitStream() call - it can prolong it more, default timeout is/may be higher. 2) Set really small connect/read timeouts before commitStream() call - what is small value? It can not be so small because it could interrupt too quickly.
          Hide
          Miroslav Fuksa added a comment -

          Timeout exception thrown during workers.writeTo() should be caught and then no commit should happen at all. This should fix the issue.

          Show
          Miroslav Fuksa added a comment - Timeout exception thrown during workers.writeTo() should be caught and then no commit should happen at all. This should fix the issue.

            People

            • Assignee:
              Adam Lindenthal
              Reporter:
              rdicroce
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - 1 hour Original Estimate - 1 hour
                1h
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 12 hours
                12h