Skip to content

Quarkus not properly shutting down results in native image trace agent log being truncated #37792

@JohT

Description

@JohT

Describe the bug

When adding the native image trace agent to integration tests to trace reflection usage, the resulting JSON file ends abruptly without the closing part and is therefore corrupt. Everything works fine with version 3.1.3.Final. The problem only occurs with version 3.2.0.CR1 and above.

Expected behavior

The integration test should be shutdown in a clean way so that the native image trace agent JSON output file is flushed.

Actual behavior

After running mvn verify --activate-profiles native-image-agent-trace locally or in the pipeline on my repository showcase-quarkus-eventsourcing, the generated JSON is corrupt (not closed correctly) and the very last lines look e.g. like this:

{"caller_class":"java.lang.invoke.InnerClassLambdaMetafactory$1", "args":[], "function":"getDeclaredConstructors", "tracer":"reflect", "class":"io.smallrye.openapi.api.OpenApiConfig$$Lambda$1757/0x00000008014abf70"},
{"caller_class":"java.lang.invoke.InnerClassLambdaMetafactory", "result":"true", "args":[[]], "declaring_class":"io.smallrye.openapi.api.OpenApiConfig$$Lambda$1757/0x00000008014abf70", "function":"invokeConstructor", "tracer":"reflect", "class":"io.smallrye.openapi.api.OpenApiConfig$$Lambda$1757/0x00000008014abf70"},
{"caller_class":"java.lang.invoke.InnerClassLambdaMetafactory$1", "args":[], "function":"getDeclaredConstructors", "tracer":"reflect", "class":"io.smallrye.openapi.api.OpenApiConfig$$Lambda$1758/0x00000008014ac190"},
{"caller_class":"java.lang.invoke.InnerClassLambdaMetafactory", "result":"true", "args":[[]], "declaring_class":"io.smallrye.openapi.api.OpenApiConfig$$Lambda$1758/0x00000008014ac190", "function":"invokeConstructor", "tracer":"reflect", "class":"io.smallrye.openapi.api.OpenApiConfig$$L

Trying to process the corrupt JSON file locally with $GRAALVM_HOME/bin/native-image-configure generate --trace-input=target/native-image-agent-trace.json or in the pipeline leads to an expected error like this:

com.oracle.svm.core.util.json.JSONParserException: line 23493 column 286 Missing close quote
        at org.graalvm.nativeimage.builder/com.oracle.svm.core.util.json.JSONParser.error(JSONParser.java:377)
        at org.graalvm.nativeimage.builder/com.oracle.svm.core.util.json.JSONParser.parseString(JSONParser.java:221)

I suspect that the JVM for testing is shutdown without waiting for files to be flushed or something like that. But that's just an idea. Don't know if this could be....

Everything is working fine with quarkus 3.1.3.Final. The change seems to had been introduced with 3.2.0.CR1:
3.1.3.Final...3.2.0.CR1

How to Reproduce?

Reproducer with detailed description: JohT/showcase-quarkus-eventsourcing#247

Output of uname -a or ver

Darwin...RELEASE_ARM64_T8101 arm64

Output of java -version

OpenJDK 64-Bit Server VM Temurin-17.0.7+7 (build 17.0.7+7, mixed mode)

Quarkus version or git rev

3.2.0.CR1

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

Apache Maven 3.9.6 (bc0240f3c744dd6b6ec2920b3cd08dcc295161ae)

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions