Skip to content

Commit 6db7097

Browse files
authored
Support spring native in main branch (Azure#28158)
* Remove non-existent proxy configuration * Update changelog and remove unused comments * Fix the problems encountered in the sample test * Sync versions in the native configuration module * Remove the configuration in the spring side due to the graalvm-aot-support has provided the config * Add azure aot netty support to fix netty native compilation issues
1 parent a8e6cf9 commit 6db7097

File tree

32 files changed

+805
-40
lines changed

32 files changed

+805
-40
lines changed

eng/versioning/external_dependencies.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ org.springframework.boot:spring-boot;2.6.6
134134
org.springframework.data:spring-data-commons;2.6.3
135135
org.springframework.data:spring-data-mongodb;3.3.3
136136
org.springframework.data:spring-data-redis;2.6.3
137+
org.springframework.experimental:spring-aot;0.11.4
137138
org.springframework.integration:spring-integration-core;5.5.10
138139
org.springframework.kafka:spring-kafka;2.8.4
139140
org.springframework.security:spring-security-config;5.6.2

eng/versioning/version_client.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ com.azure.spring:spring-cloud-azure-core;4.0.0;4.1.0-beta.1
171171
com.azure.spring:spring-cloud-azure-actuator-autoconfigure;4.0.0;4.1.0-beta.1
172172
com.azure.spring:spring-cloud-azure-actuator;4.0.0;4.1.0-beta.1
173173
com.azure.spring:spring-cloud-azure-autoconfigure;4.0.0;4.1.0-beta.1
174+
com.azure.spring:spring-cloud-azure-native-configuration;4.0.0-beta.1;4.0.0-beta.1
174175
com.azure.spring:spring-cloud-azure-resourcemanager;4.0.0;4.1.0-beta.1
175176
com.azure.spring:spring-cloud-azure-service;4.0.0;4.1.0-beta.1
176177
com.azure.spring:spring-cloud-azure-starter-active-directory;4.0.0;4.1.0-beta.1

sdk/aot/azure-aot-graalvm-support/src/main/java/com/azure/aot/graalvm/support/implementation/GraalVMFeature.java

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -44,21 +44,19 @@ default void beforeAnalysis(final BeforeAnalysisAccess access) {
4444
// Before we do that, we validate each of the classes specified can be found on the classpath.
4545
// If we can't find **all** of them, we don't proceed and we log an error to the console.
4646
final Set<String> missingClasses = new TreeSet<>(String::compareTo);
47-
if (!reflectionClasses.isEmpty()) {
48-
reflectionClasses.forEach(cls -> {
49-
if (!findClass(access, cls.getName()).isPresent()) {
50-
missingClasses.add(cls.getName());
51-
}
52-
});
47+
reflectionClasses.forEach(cls -> {
48+
if (!findClass(access, cls.getName()).isPresent()) {
49+
missingClasses.add(cls.getName());
50+
}
51+
});
5352

54-
dynamicProxies.forEach(interfaces -> {
55-
Arrays.stream(interfaces).forEach(cls -> {
56-
if (!findClass(access, cls).isPresent()) {
57-
missingClasses.add(cls);
58-
}
59-
});
53+
dynamicProxies.forEach(interfaces -> {
54+
Arrays.stream(interfaces).forEach(cls -> {
55+
if (!findClass(access, cls).isPresent()) {
56+
missingClasses.add(cls);
57+
}
6058
});
61-
}
59+
});
6260

6361
if (!missingClasses.isEmpty()) {
6462
System.out.println("AZURE SDK: Not registering Azure GraalVM support for " + getClass()

sdk/aot/azure-aot-graalvm-support/src/main/java/com/azure/aot/graalvm/support/implementation/GraalVMFeatureUtils.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,6 @@ private static Stream<String> findClassesInJar(final Feature.FeatureAccess acces
159159
.replace(".class", "");
160160

161161
if (fqcn.startsWith(packageName)) {
162-
if (!fqcn.startsWith(packageName)) {
163-
continue;
164-
}
165-
166162
classNames.add(fqcn);
167163
}
168164
}

sdk/aot/azure-aot-graalvm-support/src/main/java/com/azure/aot/graalvm/support/implementation/features/AzureCoreFeature.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,28 @@
22
// Licensed under the MIT License.
33
package com.azure.aot.graalvm.support.implementation.features;
44

5+
import com.azure.aot.graalvm.support.implementation.ClassReflectionAttributes;
56
import com.azure.aot.graalvm.support.implementation.GraalVMFeature;
67
import com.oracle.svm.core.annotate.AutomaticFeature;
78

9+
import java.util.Set;
10+
11+
import static com.azure.aot.graalvm.support.implementation.ClassReflectionAttributes.createWithAllDeclared;
12+
import static com.azure.aot.graalvm.support.implementation.GraalVMFeatureUtils.setOf;
13+
814
@AutomaticFeature
915
public class AzureCoreFeature implements GraalVMFeature {
1016

1117
@Override
1218
public String getRootPackage() {
1319
return "com.azure.core";
1420
}
21+
22+
@Override
23+
public Set<ClassReflectionAttributes> getReflectionClasses() {
24+
return setOf(
25+
createWithAllDeclared("com.azure.core.util.DateTimeRfc1123"),
26+
createWithAllDeclared("com.azure.core.http.rest.StreamResponse")
27+
);
28+
}
1529
}

sdk/aot/azure-aot-graalvm-support/src/main/java/com/azure/aot/graalvm/support/implementation/features/StorageBlobFeature.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ public Set<String[]> getDynamicProxies() {
2525
interfaces("com.azure.storage.blob.implementation.BlobsImpl$BlobsService"),
2626
interfaces("com.azure.storage.blob.implementation.BlockBlobsImpl$BlockBlobsService"),
2727
interfaces("com.azure.storage.blob.implementation.ContainersImpl$ContainersService"),
28-
interfaces("com.azure.storage.blob.implementation.DirectoriesImpl$DirectoriesService"),
2928
interfaces("com.azure.storage.blob.implementation.PageBlobsImpl$PageBlobsService"),
3029
interfaces("com.azure.storage.blob.implementation.ServicesImpl$ServicesService")
3130
);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
package com.azure.aot.graalvm.support.implementation.features;
4+
5+
import com.azure.aot.graalvm.support.implementation.GraalVMFeature;
6+
import com.oracle.svm.core.annotate.AutomaticFeature;
7+
8+
import java.util.Set;
9+
10+
import static com.azure.aot.graalvm.support.implementation.GraalVMFeatureUtils.interfaces;
11+
import static com.azure.aot.graalvm.support.implementation.GraalVMFeatureUtils.setsOf;
12+
13+
@AutomaticFeature
14+
public class StorageFileShareFeature implements GraalVMFeature {
15+
16+
@Override
17+
public String getRootPackage() {
18+
return "com.azure.storage.file.share";
19+
}
20+
21+
@Override
22+
public Set<String[]> getDynamicProxies() {
23+
return setsOf(
24+
interfaces("com.azure.storage.file.share.implementation.DirectoriesImpl$DirectoriesService"),
25+
interfaces("com.azure.storage.file.share.implementation.FilesImpl$FilesService"),
26+
interfaces("com.azure.storage.file.share.implementation.ServicesImpl$ServicesService"),
27+
interfaces("com.azure.storage.file.share.implementation.SharesImpl$SharesService")
28+
);
29+
}
30+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
package com.azure.aot.graalvm.support.implementation.features;
4+
5+
import com.azure.aot.graalvm.support.implementation.GraalVMFeature;
6+
import com.oracle.svm.core.annotate.AutomaticFeature;
7+
8+
import java.util.Set;
9+
10+
import static com.azure.aot.graalvm.support.implementation.GraalVMFeatureUtils.interfaces;
11+
import static com.azure.aot.graalvm.support.implementation.GraalVMFeatureUtils.setsOf;
12+
13+
@AutomaticFeature
14+
public class StorageQueueFeature implements GraalVMFeature {
15+
16+
@Override
17+
public String getRootPackage() {
18+
return "com.azure.storage.queue";
19+
}
20+
21+
@Override
22+
public Set<String[]> getDynamicProxies() {
23+
return setsOf(
24+
interfaces("com.azure.storage.queue.implementation.MessageIdsImpl$MessageIdsService"),
25+
interfaces("com.azure.storage.queue.implementation.MessagesImpl$MessagesService"),
26+
interfaces("com.azure.storage.queue.implementation.QueuesImpl$QueuesService"),
27+
interfaces("com.azure.storage.queue.implementation.ServicesImpl$ServicesService")
28+
);
29+
}
30+
}

sdk/spring/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@
211211
<module>spring-cloud-azure-actuator</module>
212212
<module>spring-cloud-azure-actuator-autoconfigure</module>
213213
<module>spring-cloud-azure-autoconfigure</module>
214+
<module>spring-cloud-azure-native-configuration</module>
214215
<module>spring-cloud-azure-starter-active-directory</module>
215216
<module>spring-cloud-azure-starter-active-directory-b2c</module>
216217
<module>spring-cloud-azure-starter-actuator</module>

sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/implementation/compatibility/AzureSpringBootVersionVerifier.java

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -68,19 +68,20 @@ public VerificationResult verify() {
6868
private String errorDescription() {
6969
String versionFromManifest = this.getVersionFromManifest();
7070
return StringUtils.hasText(versionFromManifest) ? String.format("Spring Boot [%s] is not compatible with this"
71-
+ " Spring Cloud Azure release train", versionFromManifest) : "Spring Boot is not compatible with this "
72-
+ "Spring Cloud Azure release train";
71+
+ " Spring Cloud Azure release", versionFromManifest) : "Spring Boot is not compatible with this "
72+
+ "Spring Cloud Azure release";
7373
}
7474

7575
private String action() {
76-
return String.format("Change Spring Boot version to one of the following versions %s .%n"
76+
return String.format("Change Spring Boot version to one of the following versions %s.%n"
7777
+ "You can find the latest Spring Boot versions here [%s]. %n"
78-
+ "If you want to learn more about the Spring Cloud Azure Release train compatibility, "
79-
+ "you can visit this page [%s] and check the [Release Trains] section.%nIf you want to disable this "
80-
+ "check, just set the property [spring.cloud.azure.compatibility-verifier.enabled=false]",
78+
+ "If you want to learn more about the Spring Cloud Azure compatibility, "
79+
+ "you can visit this page [%s] and check the [Which Version of Spring Cloud Azure Should I Use] section.%n"
80+
+ "If you want to disable this check, "
81+
+ "just set the property [spring.cloud.azure.compatibility-verifier.enabled=false]",
8182
this.acceptedVersions,
82-
"https://spring.io/projects/spring-boot#learn", "https://github.com/Azure/azure-sdk-for-java/wiki/Spring"
83-
+ "-Versions-Mapping");
83+
"https://spring.io/projects/spring-boot#learn",
84+
"https://github.com/Azure/azure-sdk-for-java/wiki/Spring-Versions-Mapping");
8485
}
8586

8687
String getVersionFromManifest() {
@@ -90,19 +91,15 @@ String getVersionFromManifest() {
9091
private boolean springBootVersionMatches() {
9192
for (String acceptedVersion : acceptedVersions) {
9293
try {
93-
boolean matched = this.matchSpringBootVersionFromManifest(acceptedVersion);
94-
if (matched) {
94+
if (this.matchSpringBootVersionFromManifest(acceptedVersion)) {
9595
return true;
9696
}
9797
} catch (FileNotFoundException e) {
9898
String versionString = stripWildCardFromVersion(acceptedVersion);
99-
String fullyQuallifiedClassName = this.supportedVersions.get(versionString);
100-
101-
if (classNameResolver.resolve(fullyQuallifiedClassName)) {
102-
if (LOGGER.isDebugEnabled()) {
103-
LOGGER.debug("Predicate for Spring Boot Version of [" + versionString + "] was matched");
104-
}
99+
String fullyQualifiedClassName = this.supportedVersions.get(versionString);
105100

101+
if (classNameResolver.resolve(fullyQualifiedClassName)) {
102+
LOGGER.debug("Predicate for Spring Boot Version of [" + versionString + "] was matched");
106103
return true;
107104
}
108105
}
@@ -113,9 +110,7 @@ private boolean springBootVersionMatches() {
113110

114111
private boolean matchSpringBootVersionFromManifest(String acceptedVersion) throws FileNotFoundException {
115112
String version = this.getVersionFromManifest();
116-
if (LOGGER.isDebugEnabled()) {
117-
LOGGER.debug("Version found in Boot manifest [" + version + "]");
118-
}
113+
LOGGER.debug("Version found in Boot manifest [{}]", version);
119114
if (!StringUtils.hasText(version)) {
120115
LOGGER.info("Cannot check Boot version from manifest");
121116
throw new FileNotFoundException("Spring Boot version not found");

0 commit comments

Comments
 (0)