Skip to content

Commit eb320e1

Browse files
deps: update dependency com.google.cloud:sdk-platform-java-config to v3.36.1 (#2738)
* deps: update dependency com.google.cloud:sdk-platform-java-config to v3.36.1 * chore: add program to regenerate reflect-config.json * chore: regenerate reflect-config.json for protobuf 1.68.0 --------- Co-authored-by: BenWhitehead <BenWhitehead@users.noreply.github.com>
1 parent f195f55 commit eb320e1

File tree

10 files changed

+277
-10
lines changed

10 files changed

+277
-10
lines changed

.github/workflows/unmanaged_dependency_check.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ jobs:
1717
# repository
1818
.kokoro/build.sh
1919
- name: Unmanaged dependency check
20-
uses: googleapis/sdk-platform-java/java-shared-dependencies/unmanaged-dependency-check@google-cloud-shared-dependencies/v3.36.0
20+
uses: googleapis/sdk-platform-java/java-shared-dependencies/unmanaged-dependency-check@google-cloud-shared-dependencies/v3.36.1
2121
with:
2222
bom-path: google-cloud-storage-bom/pom.xml

.kokoro/presubmit/graalvm-native-17.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Configure the docker image for kokoro-trampoline.
44
env_vars: {
55
key: "TRAMPOLINE_IMAGE"
6-
value: "gcr.io/cloud-devrel-public-resources/graalvm_sdk_platform_b:3.36.0"
6+
value: "gcr.io/cloud-devrel-public-resources/graalvm_sdk_platform_b:3.36.1"
77
}
88

99
env_vars: {

.kokoro/presubmit/graalvm-native.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Configure the docker image for kokoro-trampoline.
44
env_vars: {
55
key: "TRAMPOLINE_IMAGE"
6-
value: "gcr.io/cloud-devrel-public-resources/graalvm_sdk_platform_a:3.36.0"
6+
value: "gcr.io/cloud-devrel-public-resources/graalvm_sdk_platform_a:3.36.1"
77
}
88

99
env_vars: {

google-cloud-storage-bom/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
<parent>
2525
<groupId>com.google.cloud</groupId>
2626
<artifactId>sdk-platform-java-config</artifactId>
27-
<version>3.36.0</version>
27+
<version>3.36.1</version>
2828
<relativePath/>
2929
</parent>
3030

google-cloud-storage/pom.xml

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,12 @@
313313
<version>1.9.0</version>
314314
<scope>test</scope>
315315
</dependency>
316-
316+
<dependency>
317+
<groupId>io.github.classgraph</groupId>
318+
<artifactId>classgraph</artifactId>
319+
<version>4.8.176</version>
320+
<scope>test</scope>
321+
</dependency>
317322
</dependencies>
318323

319324
<build>
@@ -426,5 +431,40 @@
426431
<test>com.google.cloud.storage.it.StorageNativeCanary</test>
427432
</properties>
428433
</profile>
434+
<profile>
435+
<id>regen-grpc-graalvm-reflect-config</id>
436+
<!--
437+
to run this, execute the following commands from the base of the repo:
438+
439+
mvn -Dmaven.test.skip.exec=true clean install && cd google-cloud-storage && mvn -Pregen-grpc-graalvm-reflect-config exec:exec
440+
441+
-->
442+
<build>
443+
<plugins>
444+
<plugin>
445+
<groupId>org.codehaus.mojo</groupId>
446+
<artifactId>exec-maven-plugin</artifactId>
447+
<version>3.4.1</version>
448+
<executions>
449+
<execution>
450+
<goals>
451+
<goal>exec</goal>
452+
</goals>
453+
</execution>
454+
</executions>
455+
<configuration>
456+
<classpathScope>test</classpathScope>
457+
<addOutputToClasspath>true</addOutputToClasspath>
458+
<executable>java</executable>
459+
<arguments>
460+
<argument>-classpath</argument>
461+
<classpath/>
462+
<argument>com.google.cloud.storage.GenerateGrpcProtobufReflectConfig</argument>
463+
</arguments>
464+
</configuration>
465+
</plugin>
466+
</plugins>
467+
</build>
468+
</profile>
429469
</profiles>
430470
</project>
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
/*
2+
* Copyright 2024 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+
* http://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.storage;
18+
19+
import com.google.protobuf.AbstractMessage;
20+
import com.google.protobuf.GeneratedMessageV3;
21+
import com.google.protobuf.ProtocolMessageEnum;
22+
import io.github.classgraph.ClassGraph;
23+
import io.github.classgraph.ClassInfo;
24+
import io.github.classgraph.ScanResult;
25+
import java.io.IOException;
26+
import java.nio.charset.StandardCharsets;
27+
import java.nio.file.Files;
28+
import java.nio.file.Path;
29+
import java.nio.file.Paths;
30+
import java.util.stream.Collectors;
31+
import java.util.stream.Stream;
32+
33+
public final class GenerateGrpcProtobufReflectConfig {
34+
35+
public static void main(String[] args) throws IOException {
36+
try (ScanResult scanResult =
37+
new ClassGraph().enableAllInfo().acceptPackages("io.grpc").scan()) {
38+
String json =
39+
Stream.of(
40+
Stream.of(
41+
"{\n"
42+
+ " \"name\":\"org.apache.commons.logging.LogFactory\",\n"
43+
+ " \"allDeclaredFields\":true,\n"
44+
+ " \"allDeclaredMethods\":true,\n"
45+
+ " \"allDeclaredConstructors\": true\n"
46+
+ " }",
47+
"{\n"
48+
+ " \"name\":\"org.apache.commons.logging.impl.Jdk14Logger\",\n"
49+
+ " \"methods\":[{\"name\":\"<init>\",\"parameterTypes\":[\"java.lang.String\"] }]\n"
50+
+ " }",
51+
"{\n"
52+
+ " \"name\":\"org.apache.commons.logging.impl.LogFactoryImpl\",\n"
53+
+ " \"allDeclaredFields\":true,\n"
54+
+ " \"allDeclaredMethods\":true,\n"
55+
+ " \"methods\":[{\"name\":\"<init>\",\"parameterTypes\":[] }]\n"
56+
+ " }"),
57+
Stream.of(
58+
scanResult.getSubclasses(GeneratedMessageV3.class).stream(),
59+
scanResult.getSubclasses(AbstractMessage.Builder.class).stream(),
60+
scanResult.getAllEnums()
61+
.filter(ci -> ci.implementsInterface(ProtocolMessageEnum.class))
62+
.stream())
63+
.flatMap(s -> s)
64+
.map(ClassInfo::getName)
65+
.sorted()
66+
.map(
67+
name ->
68+
String.format(
69+
"{ \"name\": \"%s\", \"queryAllDeclaredConstructors\": true, \"queryAllPublicConstructors\": true, \"queryAllDeclaredMethods\": true, \"allPublicMethods\": true, \"allDeclaredClasses\": true, \"allPublicClasses\": true }",
70+
name)))
71+
.flatMap(s -> s)
72+
.collect(Collectors.joining(",\n ", "[\n ", "\n]\n"));
73+
String workingDirectory = System.getProperty("user.dir"); // should be google-cloud-storage
74+
String testResourcesPath = "src/test/resources";
75+
String reflectConfigResourcePath =
76+
"META-INF/native-image/com/google/cloud/storage/reflect-config.json";
77+
Path path = Paths.get(workingDirectory, testResourcesPath, reflectConfigResourcePath);
78+
System.err.println("Writing reflect-config.json at path: " + path);
79+
Files.write(path, json.getBytes(StandardCharsets.UTF_8));
80+
}
81+
}
82+
}

google-cloud-storage/src/test/java/com/google/cloud/storage/it/StorageNativeCanary.java

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import com.google.cloud.storage.Storage.BlobSourceOption;
3333
import com.google.cloud.storage.Storage.BlobWriteOption;
3434
import com.google.cloud.storage.StorageOptions;
35+
import com.google.cloud.storage.TestUtils;
3536
import com.google.common.collect.ImmutableList;
3637
import com.google.common.io.ByteStreams;
3738
import java.io.ByteArrayInputStream;
@@ -51,12 +52,12 @@ public final class StorageNativeCanary {
5152
private static final byte[] bytes = DataGenerator.base64Characters().genBytes(512 * 1024);
5253

5354
@Test
54-
public void canary_happyPath_http() throws Exception {
55+
public void canary_happyPath_http() throws Throwable {
5556
assertBehaviorOfPrimaryStorageActions(StorageOptions.http().build().getService());
5657
}
5758

5859
@Test
59-
public void canary_happyPath_grpc() throws Exception {
60+
public void canary_happyPath_grpc() throws Throwable {
6061
assertBehaviorOfPrimaryStorageActions(StorageOptions.grpc().build().getService());
6162
}
6263

@@ -84,7 +85,7 @@ public void canary_happyPath_grpc() throws Exception {
8485
* <li>Delete temporary bucket (Unary)
8586
* </ul>
8687
*/
87-
private static void assertBehaviorOfPrimaryStorageActions(Storage storage) throws Exception {
88+
private static void assertBehaviorOfPrimaryStorageActions(Storage storage) throws Throwable {
8889
// create a temporary bucket
8990
try (TemporaryBucket temporaryBucket =
9091
TemporaryBucket.newBuilder()
@@ -131,6 +132,18 @@ private static void assertBehaviorOfPrimaryStorageActions(Storage storage) throw
131132
() -> assertThat(actual.get(1).getContent()).isEqualTo(bytes),
132133
() -> assertThat(deletes.get(0)).isTrue(),
133134
() -> assertThat(deletes.get(1)).isTrue());
135+
} catch (Throwable e) {
136+
String hintMessage =
137+
"Possible missing reflect-config configuration. Run the following to regenerate grpc reflect-config: mvn -Dmaven.test.skip.exec=true clean install && cd google-cloud-storage && mvn -Pregen-grpc-graalvm-reflect-config exec:exec";
138+
Throwable linkageError = TestUtils.findThrowable(LinkageError.class, e);
139+
Throwable roe = TestUtils.findThrowable(ReflectiveOperationException.class, e);
140+
if (linkageError != null) {
141+
throw new RuntimeException(hintMessage, linkageError);
142+
} else if (roe != null) {
143+
throw new RuntimeException(hintMessage, roe);
144+
} else {
145+
throw e;
146+
}
134147
}
135148
}
136149

0 commit comments

Comments
 (0)