Uploaded image for project: 'Harmony'
  1. Harmony
  2. HARMONY-5737

[classlib][luni]FileURLConnection.connect fails in presence of anchor's

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 5.0M6
    • None
    • None

    Description

      Download the following html to your local directory

      curl -O http://www.apache.org/foundation/how-it-works.html

      and run this Test case.

      ========================
      import java.net.*;
      import java.io.*;

      public class Main {
      public static void main(String[] args) throws Exception {
      File f = new File("how-it-works.html");
      URL anchor = new URL(f.toURL(), "#meritocracy");
      System.out.println("Anchor : " + anchor);
      URLConnection connection = anchor.openConnection();
      DataInputStream dis = new DataInputStream(connection.getInputStream());
      String inputLine;

      while ((inputLine = dis.readLine()) != null)

      { System.out.println(inputLine); }

      dis.close();
      }
      }

      ========================

      Here's the stack trace :

      [dims@dims-desktop sample]$../jdk/bin/java -cp . Main
      Anchor : file:/home/dims/harmony/target/hdk/sample/how-it-works.html#meritocracy
      Uncaught exception in main:
      java.io.FileNotFoundException: /home/dims/harmony/target/hdk/sample/how-it-works.html#meritocracy
      at org.apache.harmony.luni.platform.OSFileSystem.open(OSFileSystem.java:235)
      at java.io.FileInputStream.<init>(FileInputStream.java:76)
      at org.apache.harmony.luni.internal.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:91)
      at org.apache.harmony.luni.internal.net.www.protocol.file.FileURLConnection.getInputStream(FileURLConnection.java:189)
      at Main.main(Main.java:10)

      Attachments

        1. Harmony-5737.diff
          0.7 kB
          Sean Qiu
        2. Harmony-5737-V2.diff
          2 kB
          Sean Qiu

        Activity

          People

            tony.wu Tony Wu
            dims Davanum Srinivas
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: