Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8314978

Multiple server call from connection failing with expect100 in getOutputStream

    XMLWordPrintable

Details

    • b19
    • generic
    • generic
    • Verified

    Description

      A DESCRIPTION OF THE PROBLEM :
      For calling server which is responding with non 100 statusCode.
      On an httpUrlConnection instance created for upload. If the getOutputStream() method fails with expect100 error, and then if any other method is called on that instance (ex getHeaderField(), or getHeaderFields()). They will internally call getOuputStream() which invokes writeRequests(), which make the actual server call.

      If these methods are called n times, it will try to invoke (n+1) server calls.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      //Lets assume that server return non-100 statusCode everytime server call is invoked.
      HttpUrlConnection conn = url.openConnection();
      try {
      conn.getOutputStream();
      } catch(Exception e) {}

      for(int i=0;i<n;i++) {conn.getHeaderField("headerName");}

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      There should be only one server call.
      ACTUAL -
      There would be (n+1) server calls.

      CUSTOMER SUBMITTED WORKAROUND :
      There is a variable `rememberedException` used in getInputStream0() which gets set when disconnectInternal() is called from getInputStream0(). If something like this variable can be there in getOutputStream0() which knows that the connection failed due to 100-continue error (ProtocolException here, which invokes disconnectInternal()) and returns from there.

      FREQUENCY : always


      Attachments

        Issue Links

          Activity

            People

              dclarke Darragh Clarke
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: