Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QuarkusTest wants to create TMP directory in the root directory instead of users directory on Windows machine #41124

Closed
argenstijn opened this issue Jun 11, 2024 · 9 comments · Fixed by #41147
Labels
area/testing env/windows Impacts Windows machines kind/bug Something isn't working
Milestone

Comments

@argenstijn
Copy link

argenstijn commented Jun 11, 2024

Describe the bug

When running a test using @QuarkusTest on Windows 10 machine with an user with no permission to change c:\tmp i get the following exception.

java.lang.RuntimeException: java.lang.RuntimeException: Failed to start quarkus

	at io.quarkus.test.junit.QuarkusTestExtension.throwBootFailureException(QuarkusTestExtension.java:642)
	at io.quarkus.test.junit.QuarkusTestExtension.interceptTestClassConstructor(QuarkusTestExtension.java:726)
	at java.base/java.util.Optional.orElseGet(Optional.java:364)
	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184)
	at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
	at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:179)
	at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184)
	at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
	at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
	at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184)
	at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
	at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:1024)
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
	at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151)
	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174)
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596)
	at java.base/java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:276)
	at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
	at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
	at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
	at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1708)
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
	at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151)
	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174)
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596)
	at java.base/java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:276)
	at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1708)
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
	at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151)
	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174)
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
Caused by: java.lang.RuntimeException: Failed to start quarkus
	at io.quarkus.runner.ApplicationImpl.doStart(Unknown Source)
	at io.quarkus.runtime.Application.start(Application.java:101)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at io.quarkus.runner.bootstrap.StartupActionImpl.run(StartupActionImpl.java:285)
	at io.quarkus.test.junit.QuarkusTestExtension.doJavaStart(QuarkusTestExtension.java:251)
	at io.quarkus.test.junit.QuarkusTestExtension.ensureStarted(QuarkusTestExtension.java:609)
	at io.quarkus.test.junit.QuarkusTestExtension.beforeAll(QuarkusTestExtension.java:659)
	... 1 more
Caused by: java.lang.IllegalStateException: Unable to create folder at path '/tmp/quarkus'
	at io.vertx.core.file.impl.FileCache.setupCacheDir(FileCache.java:61)
	at io.vertx.core.file.impl.FileCache.setupCache(FileCache.java:31)
	at io.vertx.core.file.impl.FileResolverImpl.<init>(FileResolverImpl.java:76)
	at io.vertx.core.impl.VertxBuilder.initFileResolver(VertxBuilder.java:338)
	at io.vertx.core.impl.VertxBuilder.init(VertxBuilder.java:278)
	at io.quarkus.vertx.core.runtime.VertxCoreRecorder.initialize(VertxCoreRecorder.java:255)
	at io.quarkus.vertx.core.runtime.VertxCoreRecorder$VertxSupplier.get(VertxCoreRecorder.java:653)
	at io.quarkus.vertx.core.runtime.VertxCoreRecorder$VertxSupplier.get(VertxCoreRecorder.java:632)
	at io.quarkus.vertx.http.runtime.VertxHttpRecorder.initializeRouter(VertxHttpRecorder.java:296)
	at io.quarkus.deployment.steps.VertxHttpProcessor$preinitializeRouter1141331088.deploy_0(Unknown Source)
	at io.quarkus.deployment.steps.VertxHttpProcessor$preinitializeRouter1141331088.deploy(Unknown Source)
	... 8 more
Caused by: java.nio.file.AccessDeniedException: C:\tmp
	at java.base/sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:89)
	at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:103)
	at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:108)
	at java.base/sun.nio.fs.WindowsFileSystemProvider.createDirectory(WindowsFileSystemProvider.java:527)
	at java.base/java.nio.file.Files.createDirectory(Files.java:699)
	at java.base/java.nio.file.Files.createAndCheckIsDirectory(Files.java:807)
	at java.base/java.nio.file.Files.createDirectories(Files.java:793)
	at io.vertx.core.file.impl.FileCache.setupCacheDir(FileCache.java:53)
	... 18 more

I am using quarkus 3.11.1. Other projects where i use the same version of Quarkus works perfectly. But there is only one thing that is different. In this project i am using the extension

	_<dependency>
			<groupId>io.quarkus</groupId>
			<artifactId>quarkus-amazon-lambda-rest</artifactId>
		</dependency>_

Below my depedencies:

	<dependencies>

		<dependency>
			<groupId>io.quarkus</groupId>
			<artifactId>quarkus-amazon-lambda-rest</artifactId>
		</dependency>

		<dependency>
			<groupId>io.quarkus</groupId>
			<artifactId>quarkus-rest</artifactId>
		</dependency>

		<dependency>
			<groupId>software.amazon.awssdk.crt</groupId>
			<artifactId>aws-crt</artifactId>
		</dependency>

		<dependency>
			<groupId>io.quarkus</groupId>
			<artifactId>quarkus-logging-json</artifactId>		
		</dependency>

		<dependency>
			<groupId>io.quarkus</groupId>
			<artifactId>quarkus-jaxb</artifactId>
		</dependency>

		<dependency>
			<groupId>io.quarkus</groupId>
			<artifactId>quarkus-arc</artifactId>
		</dependency>

		<dependency>
			<groupId>io.quarkiverse.amazonservices</groupId>
			<artifactId>quarkus-amazon-sns</artifactId>
		</dependency>

		<dependency>
			<groupId>software.amazon.awssdk</groupId>
			<artifactId>url-connection-client</artifactId>
		</dependency>

		<!-- TEST DEPENDENCIES -->
		
		<dependency>
			<groupId>io.rest-assured</groupId>
			<artifactId>rest-assured</artifactId>
			<scope>test</scope>
		</dependency>

		<dependency>
			<groupId>io.quarkus</groupId>
			<artifactId>quarkus-junit5-mockito</artifactId>
			<scope>test</scope>
		</dependency>

		<dependency>
			<groupId>io.quarkus</groupId>
			<artifactId>quarkus-junit5</artifactId>
			<scope>test</scope>
		</dependency>

		<dependency>
			<groupId>org.hamcrest</groupId>
			<artifactId>hamcrest</artifactId>
			<version>2.2</version>
			<scope>test</scope>
		</dependency>

		<dependency>
			<groupId>org.xmlunit</groupId>
			<artifactId>xmlunit-matchers</artifactId>
			<version>2.10.0</version>
			<scope>test</scope>
		</dependency>

		<!-- Support for SSO during testing against real endpoint! -->
		<dependency>
			<groupId>software.amazon.awssdk</groupId>
			<artifactId>sso</artifactId>
			<scope>test</scope>
			<exclusions>
				<exclusion>
					<groupId>software.amazon.awssdk</groupId>
					<artifactId>netty-nio-client</artifactId>
				</exclusion>
				<exclusion>
					<groupId>software.amazon.awssdk</groupId>
					<artifactId>apache-client</artifactId>
				</exclusion>
			</exclusions>
		</dependency>

		<dependency>
			<groupId>software.amazon.awssdk</groupId>
			<artifactId>ssooidc</artifactId>
			<scope>test</scope>
			<exclusions>
				<exclusion>
					<groupId>software.amazon.awssdk</groupId>
					<artifactId>netty-nio-client</artifactId>
				</exclusion>
				<exclusion>
					<groupId>software.amazon.awssdk</groupId>
					<artifactId>apache-client</artifactId>
				</exclusion>
			</exclusions>
		</dependency>
		<!--  END of Support for SSO -->


	</dependencies>

Expected behavior

All TMP files should be created in the user directory.

Actual behavior

Tries to write temp files to c:\tmp

How to Reproduce?

I needed i can create a reproducer shortly

Output of uname -a or ver

Microsoft Windows [Version 10.0.19045.4412]

Output of java -version

openjdk 21.0.2 2024-01-16 LTS OpenJDK Runtime Environment Corretto-21.0.2.13.1 (build 21.0.2+13-LTS) OpenJDK 64-Bit Server VM Corretto-21.0.2.13.1 (build 21.0.2+13-LTS, mixed mode, sharing)

Quarkus version or git rev

3.11.1

Build tool (ie. output of mvnw --version or gradlew --version)

3.9.1

Additional information

No response

@argenstijn argenstijn added the kind/bug Something isn't working label Jun 11, 2024
@quarkus-bot quarkus-bot bot added env/windows Impacts Windows machines triage/needs-triage labels Jun 11, 2024
@gsmet
Copy link
Member

gsmet commented Jun 11, 2024

You can work around it by following these instructions: https://quarkus.io/guides/vertx-reference#deploy-on-read-only-environments .

I'm not sure if the defaults for Windows should be adjusted though. @cescoffier the default is determined by Vert.x, right?

@cescoffier
Copy link
Member

It will use the JVM temporary directory. If that one is not writable, you will have to configure the directory.

@argenstijn
Copy link
Author

But for me the JVM temporary directory is writable (System.getProperty("java.io.tmpdir")). This point to
C:\Users[USER]\AppData\Local\Temp

@argenstijn
Copy link
Author

So this is the code part in vert.x i assume:

 /**
   * The default file caching dir. If the system property {@code "vertx.cacheDirBase"} is set, then this is the value
   * If not, then the system property {@code java.io.tmpdir} is taken or {code .} if not set. suffixed with {@code vertx-cache}.
   */
  public static final String DEFAULT_FILE_CACHING_DIR = System.getProperty(CACHE_DIR_BASE_PROP_NAME, TMPDIR + File.separator + DEFAULT_CACHE_DIR_BASE);

@argenstijn
Copy link
Author

Setting _-Dvertx.cacheDirBase value makes no difference in the end result.

@cescoffier
Copy link
Member

Hum, the lambda extension may override the cache dir.

@geoand
Copy link
Contributor

geoand commented Jun 12, 2024

#41147 takes care of it

@cescoffier
Copy link
Member

So, I was right, the lambda extension sets the temp directory (ignoring the user value).

@geoand
Copy link
Contributor

geoand commented Jun 12, 2024

Yup

geoand added a commit that referenced this issue Jun 12, 2024
Only set tmp dir for Lambda in normal mode
@quarkus-bot quarkus-bot bot added this to the 3.12 - main milestone Jun 12, 2024
holly-cummins pushed a commit to holly-cummins/quarkus that referenced this issue Jul 31, 2024
danielsoro pushed a commit to danielsoro/quarkus that referenced this issue Sep 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/testing env/windows Impacts Windows machines kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants