-
Type:
Bug
-
Status: Open
-
Priority:
Minor
-
Resolution: Unresolved
-
Affects Version/s: 2021.15
-
Fix Version/s: None
-
Component/s: Tests
When using test features, the OSGIRuntimeTestActivator is setting the java.io.tmpdir system property to a folder that is a subdirectory of the test runtime folder nxruntime-main-XXXXXXX.tmp. This folder is then deleted but the java.io.tmpdir is not reset so the next time a test uses the junit TemporaryFolder rule with no parent folder argument, like this:
@Rule public final TemporaryFolder tempFolder = new TemporaryFolder();
The test will fail with the following error because it cannot create a temp folder inside the directory referenced by the java.io.tmpdir property, which is already deleted :
java.nio.file.NoSuchFileException: /home/jenkins/agent/workspace/source/studio/nuxeo-studio-ui/target/nxruntime-main-1357956366142790488.tmp/tmp/junit12567900275741526972 at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:92) at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111) at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:116) at java.base/sun.nio.fs.UnixFileSystemProvider.createDirectory(UnixFileSystemProvider.java:389) at java.base/java.nio.file.Files.createDirectory(Files.java:690) at java.base/java.nio.file.TempFileHelper.create(TempFileHelper.java:135) at java.base/java.nio.file.TempFileHelper.createTempDirectory(TempFileHelper.java:172) at java.base/java.nio.file.Files.createTempDirectory(Files.java:966) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at org.junit.rules.TemporaryFolder.createTemporaryFolderWithNioApi(TemporaryFolder.java:265) at org.junit.rules.TemporaryFolder.createTemporaryFolderIn(TemporaryFolder.java:237) at org.junit.rules.TemporaryFolder.create(TemporaryFolder.java:150) at org.junit.rules.TemporaryFolder.before(TemporaryFolder.java:136) at org.junit.rules.ExternalResource$1.evaluate(ExternalResource.java:50) at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306) at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)
Note that reseting the java.io.tmpdir property may not be enough because TemporaryFolder is caching the default tmpdir in a static variable.