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

BaseDirectoryTestCase may create temporary files with names not accepted by Windows (e.g. com1, con,...)

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 6.1, 6.x, 7.0
    • Component/s: modules/test-framework
    • Labels:
      None
    • Lucene Fields:
      New

      Description

      BaseDirectoryTestCase may randomly create files with "special names", which are not allowed by certain operating systems, e.g. Windows.

      See https://msdn.microsoft.com/en-us/library/aa365247.aspx for more info.

      This is the issue we have seen:

      java.security.AccessControlException: access denied ("java.io.FilePermission" "C:\Users\jenkins\workspace\Lucene-Solr-6.x-Windows\lucene\build\core\test\J0\temp\lucene.store.TestMmapDirectory_96FC6F2D45B76809-001\tempDir-007\con" "write")
      	at __randomizedtesting.SeedInfo.seed([96FC6F2D45B76809:DE018553DD164AB]:0)
      	at java.security.AccessControlContext.checkPermission(AccessControlContext.java:472)
      	at java.security.AccessController.checkPermission(AccessController.java:884)
      	at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
      	at java.lang.SecurityManager.checkWrite(SecurityManager.java:979)
      	at sun.nio.fs.WindowsChannelFactory.open(WindowsChannelFactory.java:295)
      	at sun.nio.fs.WindowsChannelFactory.newFileChannel(WindowsChannelFactory.java:162)
      	at sun.nio.fs.WindowsFileSystemProvider.newByteChannel(WindowsFileSystemProvider.java:225)
      	at java.nio.file.spi.FileSystemProvider.newOutputStream(FileSystemProvider.java:434)
      	at org.apache.lucene.mockfile.FilterFileSystemProvider.newOutputStream(FilterFileSystemProvider.java:197)
      	at org.apache.lucene.mockfile.FilterFileSystemProvider.newOutputStream(FilterFileSystemProvider.java:197)
      	at org.apache.lucene.mockfile.HandleTrackingFS.newOutputStream(HandleTrackingFS.java:129)
      	at org.apache.lucene.mockfile.HandleTrackingFS.newOutputStream(HandleTrackingFS.java:129)
      	at org.apache.lucene.mockfile.FilterFileSystemProvider.newOutputStream(FilterFileSystemProvider.java:197)
      	at org.apache.lucene.mockfile.FilterFileSystemProvider.newOutputStream(FilterFileSystemProvider.java:197)
      	at java.nio.file.Files.newOutputStream(Files.java:216)
      	at org.apache.lucene.store.FSDirectory$FSIndexOutput.<init>(FSDirectory.java:408)
      	at org.apache.lucene.store.FSDirectory$FSIndexOutput.<init>(FSDirectory.java:404)
      	at org.apache.lucene.store.FSDirectory.createOutput(FSDirectory.java:253)
      	at org.apache.lucene.store.BaseDirectoryTestCase.testPendingDeletions(BaseDirectoryTestCase.java:1215)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:498)
      	at com.carrotsearch.randomizedtesting.RandomizedRunner.invoke(RandomizedRunner.java:1764)
      	at com.carrotsearch.randomizedtesting.RandomizedRunner$8.evaluate(RandomizedRunner.java:871)
      	at com.carrotsearch.randomizedtesting.RandomizedRunner$9.evaluate(RandomizedRunner.java:907)
      	at com.carrotsearch.randomizedtesting.RandomizedRunner$10.evaluate(RandomizedRunner.java:921)
      	at org.apache.lucene.util.TestRuleSetupTeardownChained$1.evaluate(TestRuleSetupTeardownChained.java:49)
      	at org.apache.lucene.util.AbstractBeforeAfterRule$1.evaluate(AbstractBeforeAfterRule.java:45)
      	at org.apache.lucene.util.TestRuleThreadAndTestName$1.evaluate(TestRuleThreadAndTestName.java:48)
      	at org.apache.lucene.util.TestRuleIgnoreAfterMaxFailures$1.evaluate(TestRuleIgnoreAfterMaxFailures.java:64)
      	at org.apache.lucene.util.TestRuleMarkFailure$1.evaluate(TestRuleMarkFailure.java:47)
      	at com.carrotsearch.randomizedtesting.rules.StatementAdapter.evaluate(StatementAdapter.java:36)
      	at com.carrotsearch.randomizedtesting.ThreadLeakControl$StatementRunner.run(ThreadLeakControl.java:367)
      	at com.carrotsearch.randomizedtesting.ThreadLeakControl.forkTimeoutingTask(ThreadLeakControl.java:809)
      	at com.carrotsearch.randomizedtesting.ThreadLeakControl$3.evaluate(ThreadLeakControl.java:460)
      	at com.carrotsearch.randomizedtesting.RandomizedRunner.runSingleTest(RandomizedRunner.java:880)
      	at com.carrotsearch.randomizedtesting.RandomizedRunner$5.evaluate(RandomizedRunner.java:781)
      	at com.carrotsearch.randomizedtesting.RandomizedRunner$6.evaluate(RandomizedRunner.java:816)
      	at com.carrotsearch.randomizedtesting.RandomizedRunner$7.evaluate(RandomizedRunner.java:827)
      	at org.apache.lucene.util.AbstractBeforeAfterRule$1.evaluate(AbstractBeforeAfterRule.java:45)
      	at com.carrotsearch.randomizedtesting.rules.StatementAdapter.evaluate(StatementAdapter.java:36)
      	at org.apache.lucene.util.TestRuleStoreClassName$1.evaluate(TestRuleStoreClassName.java:41)
      	at com.carrotsearch.randomizedtesting.rules.NoShadowingOrOverridesOnMethodsRule$1.evaluate(NoShadowingOrOverridesOnMethodsRule.java:40)
      	at com.carrotsearch.randomizedtesting.rules.NoShadowingOrOverridesOnMethodsRule$1.evaluate(NoShadowingOrOverridesOnMethodsRule.java:40)
      	at com.carrotsearch.randomizedtesting.rules.StatementAdapter.evaluate(StatementAdapter.java:36)
      	at com.carrotsearch.randomizedtesting.rules.StatementAdapter.evaluate(StatementAdapter.java:36)
      	at com.carrotsearch.randomizedtesting.rules.StatementAdapter.evaluate(StatementAdapter.java:36)
      	at org.apache.lucene.util.TestRuleAssertionsRequired$1.evaluate(TestRuleAssertionsRequired.java:53)
      	at org.apache.lucene.util.TestRuleMarkFailure$1.evaluate(TestRuleMarkFailure.java:47)
      	at org.apache.lucene.util.TestRuleIgnoreAfterMaxFailures$1.evaluate(TestRuleIgnoreAfterMaxFailures.java:64)
      	at org.apache.lucene.util.TestRuleIgnoreTestSuites$1.evaluate(TestRuleIgnoreTestSuites.java:54)
      	at com.carrotsearch.randomizedtesting.rules.StatementAdapter.evaluate(StatementAdapter.java:36)
      	at com.carrotsearch.randomizedtesting.ThreadLeakControl$StatementRunner.run(ThreadLeakControl.java:367)
      	at java.lang.Thread.run(Thread.java:745)
      
      1. LUCENE-7333.patch
        2 kB
        Uwe Schindler
      2. LUCENE-7333.patch
        2 kB
        Uwe Schindler

        Activity

        Hide
        thetaphi Uwe Schindler added a comment -

        The problem in this test is that it creates a file using randomSimpleString(). It is not using the temp dir / temp file functions. Not so easy to solve.

        Show
        thetaphi Uwe Schindler added a comment - The problem in this test is that it creates a file using randomSimpleString(). It is not using the temp dir / temp file functions. Not so easy to solve.
        Hide
        thetaphi Uwe Schindler added a comment -

        The createTempDir functions work fine, because they retry on IOException. So its only this test. I will fix by adding a new TestUtil function to create a random filename instead of just randomSimpleString(): randomFileName()

        Show
        thetaphi Uwe Schindler added a comment - The createTempDir functions work fine, because they retry on IOException. So its only this test. I will fix by adding a new TestUtil function to create a random filename instead of just randomSimpleString(): randomFileName()
        Hide
        thetaphi Uwe Schindler added a comment -

        Simple patch to fix this test only. I did not find any other places where a file name was created by randomSimpleString().

        Show
        thetaphi Uwe Schindler added a comment - Simple patch to fix this test only. I did not find any other places where a file name was created by randomSimpleString().
        Hide
        thetaphi Uwe Schindler added a comment -

        More realistic variant. I think that's ready; will commit tomorrow morning.

        Show
        thetaphi Uwe Schindler added a comment - More realistic variant. I think that's ready; will commit tomorrow morning.
        Hide
        mikemccand Michael McCandless added a comment -

        +1, thanks Uwe Schindler!

        Show
        mikemccand Michael McCandless added a comment - +1, thanks Uwe Schindler !
        Hide
        jira-bot ASF subversion and git services added a comment -

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

        LUCENE-7333: Fix test bug where randomSimpleString() generated a filename that is a reserved device name on Windows

        Show
        jira-bot ASF subversion and git services added a comment - Commit cc7cede7a58b4e1d0eaeb182998de69cad90c15a in lucene-solr's branch refs/heads/master from Uwe Schindler [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=cc7cede ] LUCENE-7333 : Fix test bug where randomSimpleString() generated a filename that is a reserved device name on Windows
        Hide
        jira-bot ASF subversion and git services added a comment -

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

        LUCENE-7333: Fix test bug where randomSimpleString() generated a filename that is a reserved device name on Windows

        Show
        jira-bot ASF subversion and git services added a comment - Commit b9fb98d59ac8281edd59ea8ad937f7e33b2b98b6 in lucene-solr's branch refs/heads/branch_6x from Uwe Schindler [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=b9fb98d ] LUCENE-7333 : Fix test bug where randomSimpleString() generated a filename that is a reserved device name on Windows
        Hide
        jira-bot ASF subversion and git services added a comment -

        Commit 79eb62eff311cf162a62062b0c4ce700e65284ab in lucene-solr's branch refs/heads/branch_6_1 from Uwe Schindler
        [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=79eb62e ]

        LUCENE-7333: Fix test bug where randomSimpleString() generated a filename that is a reserved device name on Windows

        Show
        jira-bot ASF subversion and git services added a comment - Commit 79eb62eff311cf162a62062b0c4ce700e65284ab in lucene-solr's branch refs/heads/branch_6_1 from Uwe Schindler [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=79eb62e ] LUCENE-7333 : Fix test bug where randomSimpleString() generated a filename that is a reserved device name on Windows

          People

          • Assignee:
            thetaphi Uwe Schindler
            Reporter:
            thetaphi Uwe Schindler
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development