commit-classpath
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[commit-cp] [bugs #10282] URLConnection.connect does not work on directo


From: Michael Koch
Subject: [commit-cp] [bugs #10282] URLConnection.connect does not work on directories
Date: Thu, 09 Sep 2004 08:24:58 -0400
User-agent: Mozilla/5.0 (compatible; Konqueror/3.2; Linux) (KHTML, like Gecko)

This mail is an automated notification from the bugs tracker
 of the project: classpath.

/**************************************************************************/
[bugs #10282] Latest Modifications:

Changes by: 
                Michael Koch <address@hidden>
'Date: 
                Don 09.09.2004 at 12:18 (GMT)

------------------ Additional Follow-up Comments ----------------------------
Another patch






/**************************************************************************/
[bugs #10282] Full Item Snapshot:

URL: <http://savannah.gnu.org/bugs/?func=detailitem&item_id=10282>
Project: classpath
Submitted by: Daniel Bonniot
On: Mon 06.09.2004 at 17:19

Category:  None
Severity:  5 - Average
Resolution:  None
Privacy:  Public
Assigned to:  None
Status:  Open
Platform Version:  None


Summary:  URLConnection.connect does not work on directories

Original Submission:  With an URL (file protocol) representing a local existing 
directory, the connect() method fails with java.io.FileNotFoundException: 
/tmp/bug/. is a directory
(tested with kaffe, sablevm and gij 3.4 on Debian GNU/Linux).
gij 3.3 does not fail on connect, but it does if you later try to open an 
InputStream from that URL.

On all Sun JVMs I could try (1.3, 1.4 and 1.5), connect() works. Furthermore, 
it's possible to read from the connection. There is some difference there. 1.3 
prints  html code (like what you'd get from a web directory listing). 1.4 and 
1.5 return one line for each file in the directory. I think it would make the 
most sense for classpath to behave the same as 1.4 and 1.5.

Here is a minimal testcase:

public class Bug
{
  public static void main(String[] args)
  {
    try {
      java.net.URL dir = new java.io.File(".").toURL();

      java.net.URLConnection con = dir.openConnection();
      // Connect should work on an existing directory
      con.connect();
      System.out.println("OK, content:");

      // Print the stream associated with the URL
      java.io.BufferedReader in = new java.io.BufferedReader
        (new java.io.InputStreamReader(con.getInputStream()));
      String line;
      for (; (line = in.readLine()) != null;)
        System.out.println(line);

    }
    catch(java.io.IOException e) {
      e.printStackTrace();
    }
  }
}


Follow-up Comments
------------------


-------------------------------------------------------
Date: Don 09.09.2004 at 12:18       By: Michael Koch <mkoch>
Another patch






File Attachments
-------------------

-------------------------------------------------------
Date: Don 09.09.2004 at 12:18  Name: file-dir.patch  Size: 2,09KB   By: mkoch

http://savannah.gnu.org/bugs/download.php?item_id=10282&amp;item_file_id=1649

-------------------------------------------------------
Date: Don 09.09.2004 at 10:11  Name: 99_connect  Size: 1,97KB   By: None
Updated patch with comments
http://savannah.gnu.org/bugs/download.php?item_id=10282&amp;item_file_id=1648

-------------------------------------------------------
Date: Mit 08.09.2004 at 20:42  Name: 99_connect  Size: 1,52KB   By: None
Proposed patch
http://savannah.gnu.org/bugs/download.php?item_id=10282&amp;item_file_id=1644






For detailed info, follow this link:
<http://savannah.gnu.org/bugs/?func=detailitem&item_id=10282>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/







reply via email to

[Prev in Thread] Current Thread [Next in Thread]