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

Add support for com.baomidou:dynamic-datasource-spring-boot-starter:3.6.1 #154

Closed
wants to merge 1 commit into from

Conversation

linghengqian
Copy link
Contributor

@linghengqian linghengqian commented Dec 21, 2022

What does this PR do?

Checklist before merging

  • I have properly formatted metadata files (see CONTRIBUTING document)
  • I have added thorough tests. (see this)

Comment on lines +24 to +44
graalvmNative {
agent {
defaultMode = "conditional"
modes {
conditional {
userCodeFilterPath = "user-code-filter.json"
}
}
metadataCopy {
mergeWithExisting = true
inputTaskNames.add("test")
outputDirectories.add("src/test/resources/META-INF/native-image/com.baomidou/dynamic-datasource-spring-boot-starter")
}
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sdeleuze

  • Hi, I noticed that when Spring Boot's Gradle Plugin is introduced, the following error will occur when executing ./gradlew -Pagent clean test.
01:21:29.638 [main] INFO org.springframework.test.context.aot.TestClassScanner - Scanning for Spring test classes in all packages in classpath roots [/home/linghengqian/TwinklingLiftWorks/git/public/graalvm-trace-metadata-smoketest/dynamic-datasource-spring-boot-starter/build/classes/java/test, /home/linghengqian/TwinklingLiftWorks/git/public/graalvm-trace-metadata-smoketest/dynamic-datasource-spring-boot-starter/build/resources/test]
Exception in thread "main" java.lang.IllegalStateException: Cannot perform AOT processing during AOT run-time execution
        at org.springframework.util.Assert.state(Assert.java:76)
        at org.springframework.test.context.aot.TestContextAotGenerator.processAheadOfTime(TestContextAotGenerator.java:126)
        at org.springframework.test.context.aot.TestAotProcessor.performAotProcessing(TestAotProcessor.java:91)
        at org.springframework.test.context.aot.TestAotProcessor.doProcess(TestAotProcessor.java:72)
        at org.springframework.test.context.aot.TestAotProcessor.doProcess(TestAotProcessor.java:39)
        at org.springframework.context.aot.AbstractAotProcessor.process(AbstractAotProcessor.java:82)
        at org.springframework.boot.test.context.SpringBootTestAotProcessor.main(SpringBootTestAotProcessor.java:57)

Copy link
Collaborator

@sdeleuze sdeleuze Feb 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@linghengqian Looks like Native Build Tools sets org.graalvm.nativeimage.imagecode system property when the agent profile is enabled (expected) but that impacts the code running in the Gradle plugin JVM potentially because the JVM is not forked and in term of lifecycle that maybe happens too early.

@bclozel @sbrannen Any thoughts ?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Running in agent mode with the NBT will set org.graalvm.nativeimage.imagecode=agent.

And AotDetector.useGeneratedArtifacts() returns true if that's the case.

So that would explain the cause of the IllegalStateException in TestContextAotGenerator.

That may be problematic in and of itself.


In any case, why is TestContextAotGenerator used when executing ./gradlew -Pagent clean test?

Is that command supposed to trigger AOT processing of the test suite?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sbrannen

  • This involves an idea that I want to use GraalVM Tracing Agent to collect GraalVM Reachability Metadata in Conditional form for the corresponding unit tests for some third-party Spring Boot Starters that must use Spring Boot's unique classes.

  • I've been involved with too many deadlines lately, and haven't had time to investigate this PR.

  • Do you want me to open a new issue with a minimal reproducible example on the Spring Boot side?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you want me to open a new issue with a minimal reproducible example on the Spring Boot side?

@linghengqian, yes that would be great!

Though it may be better to file the issue against the Spring Framework, since changes will likely need to be made in Framework -- even if the example you provide uses Boot and its plugins.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you want me to open a new issue with a minimal reproducible example on the Spring Boot side?

@linghengqian, yes that would be great!

Though it may be better to file the issue against the Spring Framework, since changes will likely need to be made in Framework -- even if the example you provide uses Boot and its plugins.

@linghengqian
Copy link
Contributor Author

linghengqian commented Jan 11, 2023

  • We don't need to consider merging this PR now because I need to confirm some of the Spring Framework's default Settings.

@linghengqian
Copy link
Contributor Author

@linghengqian
Copy link
Contributor Author

  • On the baomidou side, other committers made additional changes for Spring Boot OSS 3, which resulted in a change in package names. I'll recreate the PR for the new dependencies. This PR will be closed.

@linghengqian linghengqian deleted the dynamic-datasource branch August 8, 2023 16:30
@linghengqian
Copy link
Contributor Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for com.baomidou:dynamic-datasource-spring-boot-starter:3.6.0
3 participants