Uploaded image for project: 'Lucene - Core'
  1. Lucene - Core
  2. LUCENE-9687 Hunspell support improvements
  3. LUCENE-9730

Clean up temporary folder management in Dictionary

Details

    • Sub-task
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 9.0
    • None
    • None
    • New

    Description

      Reomve setDefaultTempDir, make getDefaultTempDir always evaluate temp dir property (no lazy init as temp. dir can change over time).

      Ideally, just remove the need for temp folder altogether by scanning a given number of lead stream bytes from within a resettable stream.

        private static Path DEFAULT_TEMP_DIR;
      
        /** Used by test framework */
        @SuppressWarnings("unused")
        public static void setDefaultTempDir(Path tempDir) {
          DEFAULT_TEMP_DIR = tempDir;
        }
      
        /**
         * Returns the default temporary directory. By default, java.io.tmpdir. If not accessible or not
         * available, an IOException is thrown
         */
        static synchronized Path getDefaultTempDir() throws IOException {
          if (DEFAULT_TEMP_DIR == null) {
            // Lazy init
            String tempDirPath = System.getProperty("java.io.tmpdir");
            if (tempDirPath == null) {
              throw new IOException("Java has no temporary folder property (java.io.tmpdir)?");
            }
            Path tempDirectory = Paths.get(tempDirPath);
            if (!Files.isWritable(tempDirectory)) {
              throw new IOException(
                  "Java's temporary folder not present or writeable?: " + tempDirectory.toAbsolutePath());
            }
            DEFAULT_TEMP_DIR = tempDirectory;
          }
      
          return DEFAULT_TEMP_DIR;
        }
      

      Attachments

        Activity

          People

            dweiss Dawid Weiss
            dweiss Dawid Weiss
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: