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

openConnection of file: URL produces ftp connection

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P4 P4
    • None
    • 1.4.0, 1.4.2
    • core-libs
    • generic, x86
    • generic, windows_xp



      Name: nt126004 Date: 09/11/2001


      java version "1.3.1"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1-root-
      010613-02:07)
      Java HotSpot(TM) Client VM (build 1.3.1, mixed mode)


      Opening a connection to a file: URL with a host specified inexplicably tries
      to do an anonymous ftp.

      public class FtpTest {
      public static void main(String [] args) {
      try {
      URL u = new URL( "file://abc/def" );
      URLConnection c = u.openConnection();
      System.err.println( c );
      } catch (Exception e) { e.printStackTrace(); }
      }
      }

      produces

      sun.net.www.protocol.ftp.FtpURLConnection:ftp://abc/def

      Why would it do that? I cannot find anything in the spec that indicates it
      would do that. But even if this is intended (albeit undocumented) behavior,
      what is the reasoning there? The likelihood that we would be able to find
      the file through anonymous ftp at the path given for the file: protocol is
      essentially zero. In fact, if we find something, it's likely NOT the file we
      want. (example: file://somehost/etc/group would translate into ftp://
      somehost/etc/group with user anonymous, which likely maps onto
      something like file://somehost/users/ftp/etc/group in the real world
      because of the anonymous ftp sandbox). Why not simply throw a nice
      exception if we can't access the file using the file: protocol, and leave it to
      the application to deal with, just like we'd do that with http, ftp and all the
      other protocols?
      (Review ID: 131632)
      ======================================================================

            alanb Alan Bateman
            nthompsosunw Nathanael Thompson (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: