FileUtil.delete(File) is a no-op if the file doesn't exist. The IOException
must be thrown due to a race with another thread. Perhaps this utility
method needs to catch the IOException and then confirm that the file
doesn't exist. If the file still exists then go ahead and throw the
IOException.

  public static void delete(File file) throws IOException {
    if (!file.exists())
      return;

    if (file.isDirectory()) {
      for (File child : listFiles(file)) {
        delete(child);
      }
    }

    Files.delete(file.toPath());
  }


On Thu, Feb 9, 2017 at 11:08 AM, Kirk Lund <kl...@pivotal.io> wrote:

> Here's the source of the exceptions in JUnit4CacheTestCase:
>
>   public static final void cleanDiskDirs() throws IOException {
>     FileUtil.delete(getDiskDir());
>     Arrays.stream(new File(".").listFiles()).forEach(file ->
> deleteBACKUPDiskStoreFile(file));
>   }
>
>   private static void deleteBACKUPDiskStoreFile(final File file) {
>     if (file.getName().startsWith("BACKUPDiskStore-")) {
>       try {
>         FileUtil.delete(file);
>       } catch (IOException e) {
>         throw new RuntimeException("Unable to delete BACKUPDiskStore
> file", e);
>       }
>     }
>   }
>
> There's probably an async thread either from tearDown or from the tests
> that's also deleting disk stores?
>
> On Thu, Feb 9, 2017 at 10:58 AM, Bruce Schuchardt <bschucha...@pivotal.io>
> wrote:
>
>> What concerns me about these failures is that it's iterating the contents
>> of a directory to delete eache file one-by-one and is failing to find a
>> file.  It's in JUnit4CacheTestCase tear-down code, not code specific to
>> distributed transactions.
>>
>>
>> Le 2/9/2017 à 10:53 AM, Kirk Lund a écrit :
>>
>>> The nightly build continues to fail with many dist tx test failures
>>> involving cleanup of diskstores. Should we delete the dist tx tests since
>>> we don't have dist tx in geode yet?
>>>
>>> https://builds.apache.org/job/Geode-nightly/743/
>>>
>>> [error 2017/02/09 11:20:30.602 UTC <RMI TCP Connection(28)-67.195.81.139>
>>> tid=0x600] Error cleaning disk dirs
>>> java.lang.RuntimeException: Unable to delete BACKUPDiskStore file
>>> at
>>> org.apache.geode.test.dunit.cache.internal.JUnit4CacheTestCa
>>> se.deleteBACKUPDiskStoreFile(JUnit4CacheTestCase.java:580)
>>> at
>>> org.apache.geode.test.dunit.cache.internal.JUnit4CacheTestCa
>>> se.lambda$cleanDiskDirs$0(JUnit4CacheTestCase.java:572)
>>> at
>>> java.util.Spliterators$ArraySpliterator.forEachRemaining(Spl
>>> iterators.java:948)
>>> at
>>> java.util.stream.ReferencePipeline$Head.forEach(ReferencePip
>>> eline.java:580)
>>> at
>>> org.apache.geode.test.dunit.cache.internal.JUnit4CacheTestCa
>>> se.cleanDiskDirs(JUnit4CacheTestCase.java:572)
>>> at
>>> org.apache.geode.test.dunit.cache.internal.JUnit4CacheTestCa
>>> se.remoteTearDown(JUnit4CacheTestCase.java:422)
>>> at
>>> org.apache.geode.test.dunit.cache.internal.JUnit4CacheTestCa
>>> se.lambda$tearDownCacheTestCase$bb17a952$1(JUnit4CacheTestCase.java:393)
>>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>> at
>>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce
>>> ssorImpl.java:62)
>>> at
>>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe
>>> thodAccessorImpl.java:43)
>>> at java.lang.reflect.Method.invoke(Method.java:498)
>>> at hydra.MethExecutor.executeObject(MethExecutor.java:245)
>>> at
>>> org.apache.geode.test.dunit.standalone.RemoteDUnitVM.execute
>>> MethodOnObject(RemoteDUnitVM.java:73)
>>> at sun.reflect.GeneratedMethodAccessor361.invoke(Unknown Source)
>>> at
>>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe
>>> thodAccessorImpl.java:43)
>>> at java.lang.reflect.Method.invoke(Method.java:498)
>>> at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:324)
>>> at sun.rmi.transport.Transport$1.run(Transport.java:200)
>>> at sun.rmi.transport.Transport$1.run(Transport.java:197)
>>> at java.security.AccessController.doPrivileged(Native Method)
>>> at sun.rmi.transport.Transport.serviceCall(Transport.java:196)
>>> at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTranspo
>>> rt.java:568)
>>> at
>>> sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TC
>>> PTransport.java:826)
>>> at
>>> sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$
>>> run$0(TCPTransport.java:683)
>>> at java.security.AccessController.doPrivileged(Native Method)
>>> at
>>> sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCP
>>> Transport.java:682)
>>> at
>>> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPool
>>> Executor.java:1142)
>>> at
>>> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoo
>>> lExecutor.java:617)
>>> at java.lang.Thread.run(Thread.java:745)
>>> Caused by: java.nio.file.NoSuchFileException:
>>> ./BACKUPDiskStore-0-0-org.apache.geode.disttx.DistributedTra
>>> nsactionDUnitTest.testPutAllWithTransactions_1.krf
>>> at sun.nio.fs.UnixException.translateToIOException(UnixExceptio
>>> n.java:86)
>>> at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
>>> at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107)
>>> at
>>> sun.nio.fs.UnixFileSystemProvider.implDelete(UnixFileSystemP
>>> rovider.java:244)
>>> at
>>> sun.nio.fs.AbstractFileSystemProvider.delete(AbstractFileSys
>>> temProvider.java:103)
>>> at java.nio.file.Files.delete(Files.java:1126)
>>> at org.apache.geode.internal.FileUtil.delete(FileUtil.java:166)
>>> at
>>> org.apache.geode.test.dunit.cache.internal.JUnit4CacheTestCa
>>> se.deleteBACKUPDiskStoreFile(JUnit4CacheTestCase.java:578)
>>> ... 28 more
>>>
>>>
>>
>

Reply via email to