1. Harmony
  2. HARMONY-3717

[classlib][luni] java.net.HttpURLConnection.getResponseCode() anomoly


    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Labels:
    • Environment:
      Windows XP SP2
      c:\java\hre50\bin\java -version
      svn = r530500, (Apr 20 2007), Windows/ia32/msvc 1310, release build
    • Estimated Complexity:


      I am trying to see if OpenJNLP works with Harmony. OpenJNLP is a pretty old implementation of the JNLP protocol w/o security. I hacked OpenJNLP to recognize Windows XP and then try to load a jnlp app from the the web (http://www.eclipse.org/swt/jws/controlexample.jnlp in this case). It fails with

      java.io.IOException: Bad Request
      at org.nanode.jnlp.JNLPParser$URLJNLPParser.openInputStream(JNLPParser.java:491)
      at org.nanode.jnlp.JNLPParser.parse(JNLPParser.java:119)
      at org.nanode.jnlp.JNLPParser.parseDescriptor(JNLPParser.java:292)
      at org.nanode.app.openjnlp.DefaultAppHandler.handleOpenURL(Unknown Source)
      at org.nanode.app.OpenJNLP.main(Unknown Source)
      Launching failed: http://www.eclipse.org/swt/jws/controlexample.jnlp

      [It works with the Sun JVM].

      Instrumenting the code shows that the following basic code is executed
      URLConnection uc = srcURL.openConnection();
      if (uc instanceof HttpURLConnection) {
      HttpURLConnection huc = (HttpURLConnection) uc;
      if (huc.getResponseCode() != HttpURLConnection.HTTP_OK)

      { throw new IOException(huc.getResponseMessage()); }


      getResponseCode() is returning error 400 and thus the app throws the exception. I noted that if I insert a call to huc.getHeaderFields() before the if that checks the response code, I will subsequently get a response 200 (HTTP_OK) and things proceed. It appears like there is some sort of race or deferral in populating the response codes here. Note that instead of calling huc.getHeaderFields(), I tried putting a 5 sec sleep in and it did NOT fix it. It doesn't look like it is a normal race.

      Note that it works with the Sun VM without any mods at all.

      Note that I am using a proxy server via -Dproxyset=true -DproxyHost=xxx -DproxyPort=yyy at the java command line.

      1. http.java
        0.6 kB
        Chris Elford
      2. network.txt
        4 kB
        Chris Elford

        Issue Links


          Chris Elford made changes -
          Status Resolved [ 5 ] Closed [ 6 ]
          Tim Ellison made changes -
          Status Open [ 1 ] Resolved [ 5 ]
          Resolution Fixed [ 1 ]
          Assignee Tim Ellison [ tellison ]
          Chris Elford made changes -
          Attachment network.txt [ 12370007 ]
          Chris Elford made changes -
          Link This issue is related to HARMONY-4775 [ HARMONY-4775 ]
          Chris Elford made changes -
          Attachment http.java [ 12369927 ]
          Alexey Petrenko made changes -
          Field Original Value New Value
          Component/s App-Oriented Bug Reports [ 12311280 ]
          Summary java.net.HttpURLConnection.getResponseCode() anomoly [classlib][luni] java.net.HttpURLConnection.getResponseCode() anomoly
          Chris Elford created issue -


            • Assignee:
              Tim Ellison
              Chris Elford
            • Votes:
              0 Vote for this issue
              5 Start watching this issue


              • Created: