Uploaded image for project: 'Sling'
  1. Sling
  2. SLING-7090

RRD4J metrics reporter does not close file on deactivate

    XMLWordPrintableJSON

Details

    Description

      The RRD4J metrics reporter does not close the underlying database file on deactivate. Running the tests on windows will show the following failure:

      java.lang.RuntimeException: Unable to invoke method 'activate' for class org.apache.sling.commons.metrics.rrd4j.impl.CodahaleMetricsReporter
      
      	at org.apache.sling.testing.mock.osgi.OsgiServiceUtil.invokeMethod(OsgiServiceUtil.java:320)
      	at org.apache.sling.testing.mock.osgi.OsgiServiceUtil.invokeLifecycleMethod(OsgiServiceUtil.java:213)
      	at org.apache.sling.testing.mock.osgi.OsgiServiceUtil.activateDeactivate(OsgiServiceUtil.java:84)
      	at org.apache.sling.testing.mock.osgi.MockOsgi.activate(MockOsgi.java:171)
      	at org.apache.sling.testing.mock.osgi.MockOsgi.activate(MockOsgi.java:182)
      	at org.apache.sling.commons.metrics.rrd4j.impl.ReporterTest.reconfigure(ReporterTest.java:91)
      	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 org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
      	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
      	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
      	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
      	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
      	at org.junit.rules.ExternalResource$1.evaluate(ExternalResource.java:48)
      	at org.junit.rules.RunRules.evaluate(RunRules.java:20)
      	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
      	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
      	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
      	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
      	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
      	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
      	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
      	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
      	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
      	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
      	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
      	at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:51)
      	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
      	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
      Caused by: java.nio.file.FileSystemException: target\metrics\metrics.rrd -> target\metrics\metrics.rrd.0: The process cannot access the file because it is being used by another process.
      
      	at sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:86)
      	at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:97)
      	at sun.nio.fs.WindowsFileCopy.move(WindowsFileCopy.java:387)
      	at sun.nio.fs.WindowsFileSystemProvider.move(WindowsFileSystemProvider.java:287)
      	at java.nio.file.Files.move(Files.java:1395)
      	at org.apache.sling.commons.metrics.rrd4j.impl.RRD4JReporter.rename(RRD4JReporter.java:387)
      	at org.apache.sling.commons.metrics.rrd4j.impl.RRD4JReporter.renameDB(RRD4JReporter.java:369)
      	at org.apache.sling.commons.metrics.rrd4j.impl.RRD4JReporter.createDB(RRD4JReporter.java:350)
      	at org.apache.sling.commons.metrics.rrd4j.impl.RRD4JReporter.<init>(RRD4JReporter.java:195)
      	at org.apache.sling.commons.metrics.rrd4j.impl.RRD4JReporter$Builder.build(RRD4JReporter.java:161)
      	at org.apache.sling.commons.metrics.rrd4j.impl.CodahaleMetricsReporter.activate(CodahaleMetricsReporter.java:138)
      	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 org.apache.sling.testing.mock.osgi.OsgiServiceUtil.invokeMethod(OsgiServiceUtil.java:311)
      

      This was also reported on the sling mailing list: https://lists.apache.org/thread.html/7cda3b819f4138e31e9c084511e53ca3eebffbeb56cc689396d438cd@%3Cdev.sling.apache.org%3E

      Attachments

        1. SLING-7090.patch
          0.6 kB
          Marcel Reutegger

        Issue Links

          Activity

            People

              rombert Robert Munteanu
              mreutegg Marcel Reutegger
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: