Uploaded image for project: 'Solr'
  1. Solr
  2. SOLR-9902

StandardDirectoryFactory should use Files API for it's move implementation.

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 6.4, 7.0
    • Component/s: None
    • Security Level: Public (Default Security Level. Issues are Public)
    • Labels:
      None

      Description

      It's done in a platform independent way as opposed to the old File API.

        Issue Links

          Activity

          Hide
          dsmiley David Smiley added a comment -

          Why does your patch do this:

          FileSystems.getDefault().getPath(path1.toString(), fileName)

          Instead of simply:

          path1.resolve(fileName)
          Show
          dsmiley David Smiley added a comment - Why does your patch do this: FileSystems.getDefault().getPath(path1.toString(), fileName) Instead of simply: path1.resolve(fileName)
          Hide
          markrmiller@gmail.com Mark Miller added a comment -

          Probably because I cut and pasted it from the Path javadoc. Not the only code that offers more than one way to do the same thing.

          Accessing Files
          
          Paths may be used with the Files class to operate on files, directories, and other types of files. For example, suppose we want a BufferedReader to read text from a file "access.log". The file is located in a directory "logs" relative to the current working directory and is UTF-8 encoded.
          
               Path path = FileSystems.getDefault().getPath("logs", "access.log");
               BufferReader reader = Files.newBufferedReader(path, StandardCharsets.UTF_8);
          
          Show
          markrmiller@gmail.com Mark Miller added a comment - Probably because I cut and pasted it from the Path javadoc. Not the only code that offers more than one way to do the same thing. Accessing Files Paths may be used with the Files class to operate on files, directories, and other types of files. For example, suppose we want a BufferedReader to read text from a file "access.log". The file is located in a directory "logs" relative to the current working directory and is UTF-8 encoded. Path path = FileSystems.getDefault().getPath("logs", "access.log"); BufferReader reader = Files.newBufferedReader(path, StandardCharsets.UTF_8);
          Hide
          jira-bot ASF subversion and git services added a comment -

          Commit 2781145eb3760489922530fd92d5f1d4c35215a9 in lucene-solr's branch refs/heads/master from markrmiller
          [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=2781145 ]

          SOLR-9902: StandardDirectoryFactory should use Files API for it's move implementation.

          Show
          jira-bot ASF subversion and git services added a comment - Commit 2781145eb3760489922530fd92d5f1d4c35215a9 in lucene-solr's branch refs/heads/master from markrmiller [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=2781145 ] SOLR-9902 : StandardDirectoryFactory should use Files API for it's move implementation.
          Hide
          jira-bot ASF subversion and git services added a comment -

          Commit cbf96e0d7572a28141226d92f978b8aef8bd2509 in lucene-solr's branch refs/heads/branch_6x from markrmiller
          [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=cbf96e0 ]

          SOLR-9902: StandardDirectoryFactory should use Files API for it's move implementation.

          Show
          jira-bot ASF subversion and git services added a comment - Commit cbf96e0d7572a28141226d92f978b8aef8bd2509 in lucene-solr's branch refs/heads/branch_6x from markrmiller [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=cbf96e0 ] SOLR-9902 : StandardDirectoryFactory should use Files API for it's move implementation.
          Hide
          jira-bot ASF subversion and git services added a comment -

          Commit 8bc151d1c61932dda26c682cf2281535f0c36058 in lucene-solr's branch refs/heads/master from markrmiller
          [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=8bc151d ]

          SOLR-9902: Fix move impl.

          Show
          jira-bot ASF subversion and git services added a comment - Commit 8bc151d1c61932dda26c682cf2281535f0c36058 in lucene-solr's branch refs/heads/master from markrmiller [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=8bc151d ] SOLR-9902 : Fix move impl.
          Hide
          jira-bot ASF subversion and git services added a comment -

          Commit 8fca7442716ad3397096fc271b1b9c22dd436d53 in lucene-solr's branch refs/heads/branch_6x from markrmiller
          [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=8fca744 ]

          SOLR-9902: Fix move impl.

          Show
          jira-bot ASF subversion and git services added a comment - Commit 8fca7442716ad3397096fc271b1b9c22dd436d53 in lucene-solr's branch refs/heads/branch_6x from markrmiller [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=8fca744 ] SOLR-9902 : Fix move impl.
          Hide
          mdrob Mike Drob added a comment -

          One more clarification I'd be interested in here...

          If Files.move fails for whatever reason, would it make sense to fall back to the super.move implementation or is throwing the exception sufficient for a best effort attempt here?

          Show
          mdrob Mike Drob added a comment - One more clarification I'd be interested in here... If Files.move fails for whatever reason, would it make sense to fall back to the super.move implementation or is throwing the exception sufficient for a best effort attempt here?
          Hide
          markrmiller@gmail.com Mark Miller added a comment -

          I think it probably makes sense to throw an exception. For index integrity we really need a move rather than creating a new file unless the directory factory is ephemeral - so we don't want to easily hide move not working when using local fs or make it a normal path that we try multiple ways to move a file (beyond attempting an atomic move first). If neither an atomic or std move work, something should be very wrong.

          Show
          markrmiller@gmail.com Mark Miller added a comment - I think it probably makes sense to throw an exception. For index integrity we really need a move rather than creating a new file unless the directory factory is ephemeral - so we don't want to easily hide move not working when using local fs or make it a normal path that we try multiple ways to move a file (beyond attempting an atomic move first). If neither an atomic or std move work, something should be very wrong.

            People

            • Assignee:
              markrmiller@gmail.com Mark Miller
              Reporter:
              markrmiller@gmail.com Mark Miller
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development