Skip to content

Error in the AOT test process if there are two tests that check an actuator endpoint. #34337

Closed as not planned
@ruben-garciapariente

Description

@ruben-garciapariente

Hello

I'am using SB 3.0.2. I'm trying to pass the tests with native compilation with mvn -PnativeTest clean install and I get the following error

2023-02-22T09:14:51.320+01:00  WARN 28134 --- [           main] o.s.t.c.aot.TestContextAotGenerator      : Failed to generate AOT artifacts for test classes [com.example.testactuatornative.Test2ITTest]

java.lang.IllegalStateException: java.nio.file.FileAlreadyExistsException: /home/n129586/wks/test/test-actuator-native/target/spring-aot/test/sources/org/springframework/boot/actuate/autoconfigure/endpoint/web/CorsEndpointProperties__ManagementBeanDefinitions.java
        at org.springframework.aot.generate.FileSystemGeneratedFiles.addFile(FileSystemGeneratedFiles.java:97) ~[spring-core-6.0.4.jar:6.0.4]
        at org.springframework.aot.generate.GeneratedFiles.addFile(GeneratedFiles.java:149) ~[spring-core-6.0.4.jar:6.0.4]
        at org.springframework.aot.generate.GeneratedFiles.addSourceFile(GeneratedFiles.java:70) ~[spring-core-6.0.4.jar:6.0.4]
        at org.springframework.aot.generate.GeneratedFiles.addSourceFile(GeneratedFiles.java:47) ~[spring-core-6.0.4.jar:6.0.4]
        at org.springframework.aot.generate.GeneratedClasses.writeTo(GeneratedClasses.java:198) ~[spring-core-6.0.4.jar:6.0.4]
        at org.springframework.aot.generate.DefaultGenerationContext.writeGeneratedContent(DefaultGenerationContext.java:127) ~[spring-core-6.0.4.jar:6.0.4]
        at org.springframework.test.context.aot.TestContextAotGenerator.lambda$processAheadOfTime$4(TestContextAotGenerator.java:209) ~[spring-test-6.0.4.jar:6.0.4]
        at java.base/java.util.Map.forEach(Map.java:713) ~[na:na]
        at org.springframework.test.context.aot.TestContextAotGenerator.processAheadOfTime(TestContextAotGenerator.java:197) ~[spring-test-6.0.4.jar:6.0.4]
        at org.springframework.test.context.aot.TestContextAotGenerator.processAheadOfTime(TestContextAotGenerator.java:159) ~[spring-test-6.0.4.jar:6.0.4]
        at org.springframework.test.context.aot.TestAotProcessor.performAotProcessing(TestAotProcessor.java:91) ~[spring-test-6.0.4.jar:6.0.4]
        at org.springframework.test.context.aot.TestAotProcessor.doProcess(TestAotProcessor.java:72) ~[spring-test-6.0.4.jar:6.0.4]
        at org.springframework.test.context.aot.TestAotProcessor.doProcess(TestAotProcessor.java:39) ~[spring-test-6.0.4.jar:6.0.4]
        at org.springframework.context.aot.AbstractAotProcessor.process(AbstractAotProcessor.java:82) ~[spring-context-6.0.4.jar:6.0.4]
        at org.springframework.boot.test.context.SpringBootTestAotProcessor.main(SpringBootTestAotProcessor.java:57) ~[spring-boot-test-3.0.2.jar:3.0.2]
Caused by: java.nio.file.FileAlreadyExistsException: /home/n129586/wks/test/test-actuator-native/target/spring-aot/test/sources/org/springframework/boot/actuate/autoconfigure/endpoint/web/CorsEndpointProperties__ManagementBeanDefinitions.java
        at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:94) ~[na:na]
        at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:106) ~[na:na]
        at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111) ~[na:na]
        at java.base/sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:218) ~[na:na]
        at java.base/java.nio.file.spi.FileSystemProvider.newOutputStream(FileSystemProvider.java:484) ~[na:na]
        at java.base/java.nio.file.Files.newOutputStream(Files.java:228) ~[na:na]
        at java.base/java.nio.file.Files.copy(Files.java:3160) ~[na:na]
        at org.springframework.aot.generate.FileSystemGeneratedFiles.addFile(FileSystemGeneratedFiles.java:93) ~[spring-core-6.0.4.jar:6.0.4]
        ... 14 common frames omitted

I think this happens if I have two tests of type @SpringBootTest with property management.server.port=0.

I have tried to create a minimal example: https://github.com/ruben-garciapariente/test-actuator-native

Thanks & regards

Metadata

Metadata

Assignees

No one assigned

    Labels

    for: external-projectFor an external project and not something we can fixtheme: aotAn issue related to Ahead-of-time processingtype: bugA general bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions