Skip to content

Commit 55d3fbe

Browse files
chore: add JDK 17 to Native Tests pool (#3723)
* chore: add JDK 17 to Native Tests pool [Context doc](https://docs.google.com/document/d/1bOeGtVFLsq5ts71If5pFXCvHIeNpbtBRvF6XQfavLZs/edit?tab=t.0#heading=h.gxq6ycxusimq) * deps: update cloud-sql-socket-factory to 1.25.0 This removes the unsupported EnableExperimentalVMOptions flag in their native configuration * feat: add runtime hints for secret manager * docs: improve secret manager sample config comments * chore: add license headers to new secretmanager files * chore: add clarifying comment about runtime hints for JDK 17
1 parent 3b06a2f commit 55d3fbe

File tree

6 files changed

+86
-4
lines changed

6 files changed

+86
-4
lines changed

.github/workflows/NativeTests.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ jobs:
2626
fail-fast: false
2727
matrix:
2828
graalvm_for_jdk_version:
29+
- 17
2930
- 21
3031
- 23
3132
it:

spring-cloud-gcp-dependencies/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535

3636
<properties>
3737
<gcp-libraries-bom.version>26.57.0</gcp-libraries-bom.version>
38-
<cloud-sql-socket-factory.version>1.23.1</cloud-sql-socket-factory.version>
38+
<cloud-sql-socket-factory.version>1.25.0</cloud-sql-socket-factory.version>
3939
<r2dbc-postgres-driver.version>1.0.7.RELEASE</r2dbc-postgres-driver.version>
4040
<cloud-spanner-r2dbc.version>1.3.0</cloud-spanner-r2dbc.version>
4141
<alloydb-jdbc-connector.version>1.2.0</alloydb-jdbc-connector.version>

spring-cloud-gcp-samples/spring-cloud-gcp-secretmanager-sample/src/main/resources/application.properties

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@
44
# Please refer to the Spring Cloud GCP Secret Manager reference documentation for the full protocol syntax.
55

66
# You can also specify a secret from another project.
7-
# example.property=${sm://MY_PROJECT/MY_SECRET_ID/MY_VERSION}
7+
# example.property=${sm@MY_PROJECT/MY_SECRET_ID/MY_VERSION}
88

99
# Using SpEL, you can reference an environment variable and fallback to a secret if it is missing.
10-
# example.secret=${MY_ENV_VARIABLE:${sm://application-secret/latest}}
10+
# example.secret=${MY_ENV_VARIABLE:${sm@application-secret/latest}}
1111

1212
management.endpoints.web.exposure.include=refresh
13-
# enable external resource from GCP Secret Manager.
13+
14+
# Enable external resource from GCP Secret Manager.
1415
# Here we enable the config loader for GCP Secret Manager
1516
# The sm:// syntax has been Deprecated and may be removed in a future version of
1617
# Spring Cloud GCP. Please use the sm@ syntax instead.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Copyright 2025 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.google.cloud.spring.secretmanager.aot;
18+
19+
import com.google.cloud.spring.secretmanager.SecretManagerSyntaxUtils;
20+
import java.util.Arrays;
21+
import org.springframework.aot.hint.MemberCategory;
22+
import org.springframework.aot.hint.RuntimeHints;
23+
import org.springframework.aot.hint.RuntimeHintsRegistrar;
24+
import org.springframework.aot.hint.TypeReference;
25+
26+
/**
27+
* Runtime Hints for Secret Manager. For now, this is only necessary to enable image generation with
28+
* GraalVM for JDK 17. GraalVM for JDK 21 and 23 do not need this hint.
29+
*/
30+
public class SecretManagerRuntimeHints implements RuntimeHintsRegistrar {
31+
@Override
32+
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
33+
hints
34+
.reflection()
35+
.registerTypes(
36+
Arrays.asList(TypeReference.of(SecretManagerSyntaxUtils.class)),
37+
hint ->
38+
hint.withMembers(
39+
MemberCategory.INVOKE_DECLARED_CONSTRUCTORS,
40+
MemberCategory.INVOKE_PUBLIC_METHODS));
41+
}
42+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
org.springframework.aot.hint.RuntimeHintsRegistrar=\
2+
com.google.cloud.spring.secretmanager.aot.SecretManagerRuntimeHints
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* Copyright 2025 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.google.cloud.spring.secretmanager.aot;
18+
19+
import static org.assertj.core.api.Assertions.assertThat;
20+
import static org.springframework.aot.hint.predicate.RuntimeHintsPredicates.reflection;
21+
22+
import com.google.cloud.spring.secretmanager.SecretManagerSyntaxUtils;
23+
import org.junit.jupiter.api.Test;
24+
import org.springframework.aot.hint.RuntimeHints;
25+
26+
public class SecretManagerRuntimeHintsTest {
27+
@Test
28+
void shouldRegisterHints() {
29+
RuntimeHints hints = new RuntimeHints();
30+
new SecretManagerRuntimeHints().registerHints(hints, getClass().getClassLoader());
31+
32+
assertThat(hints)
33+
.matches(reflection().onType(SecretManagerSyntaxUtils.class));
34+
}
35+
}
36+

0 commit comments

Comments
 (0)