Uploaded image for project: 'CXF'
  1. CXF
  2. CXF-3211

Infinite loop in FileUtils.getDefaultTempDir() when "java.io.tmpdir" directory is not writable

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.2.6
    • 2.3.2, 2.4
    • Core
    • None

    Description

      FileUtils.getDefaultTempDir() can go into a infinite loop when the "java.io.tmpdir" system property is set to an non-writable directory.

      See issue #CXF-1924.

      May be something like this would prevent an infinite loop :

      s = System.getProperty("java.io.tmpdir");
      File checkExists = new File(s);
      if (!checkExists.exists() || !checkExists.isDirectory() || !checkExists.canWrite()) {
      throw new RuntimeException("The directory "
      + checkExists.getAbsolutePath()
      + " is not a writable directory");
      }
      File f = new File(s, "cxf-tmp-" + x);
      for (int attempts=0; attempts<10; attempts++) {
      x = (int)(Math.random() * 1000000);
      f = new File(s, "cxf-tmp-" + x);
      if (f.mkdir()) break;
      }

      Attachments

        Activity

          People

            njiang Willem Jiang
            eric.citaire Eric Citaire
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: