Uploaded image for project: 'Lucene - Core'
  1. Lucene - Core
  2. LUCENE-6770

FSDirectory ctor should use getAbsolutePath instead of getRealPath for directory

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 5.2.1
    • Fix Version/s: 5.4, 6.0
    • Component/s: core/store
    • Labels:
      None
    • Environment:

      OS X, Linux

    • Lucene Fields:
      New, Patch Available

      Description

      After upgrade from 4.1 to 5.2.1 I found that one of our test failed. Appeared the guilty was FSDirectory that converts given Path to Path.getRealPath. As result the test will fail:

      Path p = Paths.get("/var/lucene_store");
      FSDirectory d = new FSDirectory(p);
      assertEquals(p.toString(), d.getDirectory().toString());

      It because /var/lucene_store is a symlink and
      Path directory =path.getRealPath();
      resolves it to /private/var/lucene_store

      I think this is bad design decision because "direcrory" isn't just internal state but is exposed in a public interface and "getDirectory()" is widely used to initialize other components.

      It should use paths.getAbsolutePath() instead.

      build and "ant test" were successful after fix.

        Attachments

        1. LUCENE-6770.patch
          2 kB
          Uwe Schindler
        2. LUCENE-6770.patch
          0.6 kB
          Vladimir Kuzmin

          Activity

            People

            • Assignee:
              thetaphi Uwe Schindler
              Reporter:
              kuzminva Vladimir Kuzmin
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: