Uploaded image for project: 'Hadoop Common'
  1. Hadoop Common
  2. HADOOP-12991

Conflicting default ports in DelegateToFileSystem

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.7.2
    • Fix Version/s: 2.8.0, 2.7.4, 3.0.0-alpha1
    • Component/s: fs
    • Labels:
      None
    • Hadoop Flags:
      Reviewed

      Description

      HADOOP-12304 introduced logic to ensure that the DelegateToFileSystem constructor sets the default port to -1:

      DelegateToFileSystem.java
        protected DelegateToFileSystem(URI theUri, FileSystem theFsImpl,
            Configuration conf, String supportedScheme, boolean authorityRequired)
            throws IOException, URISyntaxException {
          super(theUri, supportedScheme, authorityRequired, 
              getDefaultPortIfDefined(theFsImpl));
          fsImpl = theFsImpl;
          fsImpl.initialize(theUri, conf);
          fsImpl.statistics = getStatistics();
        }
      
        private static int getDefaultPortIfDefined(FileSystem theFsImpl) {
          int defaultPort = theFsImpl.getDefaultPort();
          return defaultPort != 0 ? defaultPort : -1;
        }
      

      However, DelegateToFileSystem#getUriDefaultPort returns 0:

      DelegateToFileSystem.java
        public int getUriDefaultPort() {
          return 0;
        }
      

      This breaks AbstractFileSystem#checkPath:

      AbstractFileSystem.java
          int thisPort = this.getUri().getPort(); // If using DelegateToFileSystem, this is -1
          int thatPort = uri.getPort(); // This is -1 by default in java.net.URI
          if (thatPort == -1) {
            thatPort = this.getUriDefaultPort();  // Sets thatPort to 0
          }
          if (thisPort != thatPort) {
            throw new InvalidPathException("Wrong FS: " + path + ", expected: "
                + this.getUri());
          }
      

      Which breaks any subclasses of DelegateToFileSystem that don't specify a port.

        Attachments

        1. HADOOP-12991.01.patch
          5 kB
          Kai Sasaki
        2. HADOOP-12991.02.patch
          5 kB
          Kai Sasaki
        3. HADOOP-12991.03.patch
          5 kB
          Kai Sasaki

          Issue Links

            Activity

              People

              • Assignee:
                lewuathe Kai Sasaki
                Reporter:
                hogeland Kevin Hogeland
              • Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: