Skip to content

Commit

Permalink
deps: update dependency com.google.cloud:sdk-platform-java-config to …
Browse files Browse the repository at this point in the history
…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 <[email protected]>
  • Loading branch information
renovate-bot and BenWhitehead authored Sep 26, 2024
1 parent f195f55 commit eb320e1
Show file tree
Hide file tree
Showing 10 changed files with 277 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/unmanaged_dependency_check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ jobs:
# repository
.kokoro/build.sh
- name: Unmanaged dependency check
uses: googleapis/sdk-platform-java/java-shared-dependencies/unmanaged-dependency-check@google-cloud-shared-dependencies/v3.36.0
uses: googleapis/sdk-platform-java/java-shared-dependencies/unmanaged-dependency-check@google-cloud-shared-dependencies/v3.36.1
with:
bom-path: google-cloud-storage-bom/pom.xml
2 changes: 1 addition & 1 deletion .kokoro/presubmit/graalvm-native-17.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Configure the docker image for kokoro-trampoline.
env_vars: {
key: "TRAMPOLINE_IMAGE"
value: "gcr.io/cloud-devrel-public-resources/graalvm_sdk_platform_b:3.36.0"
value: "gcr.io/cloud-devrel-public-resources/graalvm_sdk_platform_b:3.36.1"
}

env_vars: {
Expand Down
2 changes: 1 addition & 1 deletion .kokoro/presubmit/graalvm-native.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Configure the docker image for kokoro-trampoline.
env_vars: {
key: "TRAMPOLINE_IMAGE"
value: "gcr.io/cloud-devrel-public-resources/graalvm_sdk_platform_a:3.36.0"
value: "gcr.io/cloud-devrel-public-resources/graalvm_sdk_platform_a:3.36.1"
}

env_vars: {
Expand Down
2 changes: 1 addition & 1 deletion google-cloud-storage-bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<parent>
<groupId>com.google.cloud</groupId>
<artifactId>sdk-platform-java-config</artifactId>
<version>3.36.0</version>
<version>3.36.1</version>
<relativePath/>
</parent>

Expand Down
42 changes: 41 additions & 1 deletion google-cloud-storage/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,12 @@
<version>1.9.0</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>io.github.classgraph</groupId>
<artifactId>classgraph</artifactId>
<version>4.8.176</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down Expand Up @@ -426,5 +431,40 @@
<test>com.google.cloud.storage.it.StorageNativeCanary</test>
</properties>
</profile>
<profile>
<id>regen-grpc-graalvm-reflect-config</id>
<!--
to run this, execute the following commands from the base of the repo:
mvn -Dmaven.test.skip.exec=true clean install && cd google-cloud-storage && mvn -Pregen-grpc-graalvm-reflect-config exec:exec
-->
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.4.1</version>
<executions>
<execution>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<classpathScope>test</classpathScope>
<addOutputToClasspath>true</addOutputToClasspath>
<executable>java</executable>
<arguments>
<argument>-classpath</argument>
<classpath/>
<argument>com.google.cloud.storage.GenerateGrpcProtobufReflectConfig</argument>
</arguments>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.google.cloud.storage;

import com.google.protobuf.AbstractMessage;
import com.google.protobuf.GeneratedMessageV3;
import com.google.protobuf.ProtocolMessageEnum;
import io.github.classgraph.ClassGraph;
import io.github.classgraph.ClassInfo;
import io.github.classgraph.ScanResult;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public final class GenerateGrpcProtobufReflectConfig {

public static void main(String[] args) throws IOException {
try (ScanResult scanResult =
new ClassGraph().enableAllInfo().acceptPackages("io.grpc").scan()) {
String json =
Stream.of(
Stream.of(
"{\n"
+ " \"name\":\"org.apache.commons.logging.LogFactory\",\n"
+ " \"allDeclaredFields\":true,\n"
+ " \"allDeclaredMethods\":true,\n"
+ " \"allDeclaredConstructors\": true\n"
+ " }",
"{\n"
+ " \"name\":\"org.apache.commons.logging.impl.Jdk14Logger\",\n"
+ " \"methods\":[{\"name\":\"<init>\",\"parameterTypes\":[\"java.lang.String\"] }]\n"
+ " }",
"{\n"
+ " \"name\":\"org.apache.commons.logging.impl.LogFactoryImpl\",\n"
+ " \"allDeclaredFields\":true,\n"
+ " \"allDeclaredMethods\":true,\n"
+ " \"methods\":[{\"name\":\"<init>\",\"parameterTypes\":[] }]\n"
+ " }"),
Stream.of(
scanResult.getSubclasses(GeneratedMessageV3.class).stream(),
scanResult.getSubclasses(AbstractMessage.Builder.class).stream(),
scanResult.getAllEnums()
.filter(ci -> ci.implementsInterface(ProtocolMessageEnum.class))
.stream())
.flatMap(s -> s)
.map(ClassInfo::getName)
.sorted()
.map(
name ->
String.format(
"{ \"name\": \"%s\", \"queryAllDeclaredConstructors\": true, \"queryAllPublicConstructors\": true, \"queryAllDeclaredMethods\": true, \"allPublicMethods\": true, \"allDeclaredClasses\": true, \"allPublicClasses\": true }",
name)))
.flatMap(s -> s)
.collect(Collectors.joining(",\n ", "[\n ", "\n]\n"));
String workingDirectory = System.getProperty("user.dir"); // should be google-cloud-storage
String testResourcesPath = "src/test/resources";
String reflectConfigResourcePath =
"META-INF/native-image/com/google/cloud/storage/reflect-config.json";
Path path = Paths.get(workingDirectory, testResourcesPath, reflectConfigResourcePath);
System.err.println("Writing reflect-config.json at path: " + path);
Files.write(path, json.getBytes(StandardCharsets.UTF_8));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import com.google.cloud.storage.Storage.BlobSourceOption;
import com.google.cloud.storage.Storage.BlobWriteOption;
import com.google.cloud.storage.StorageOptions;
import com.google.cloud.storage.TestUtils;
import com.google.common.collect.ImmutableList;
import com.google.common.io.ByteStreams;
import java.io.ByteArrayInputStream;
Expand All @@ -51,12 +52,12 @@ public final class StorageNativeCanary {
private static final byte[] bytes = DataGenerator.base64Characters().genBytes(512 * 1024);

@Test
public void canary_happyPath_http() throws Exception {
public void canary_happyPath_http() throws Throwable {
assertBehaviorOfPrimaryStorageActions(StorageOptions.http().build().getService());
}

@Test
public void canary_happyPath_grpc() throws Exception {
public void canary_happyPath_grpc() throws Throwable {
assertBehaviorOfPrimaryStorageActions(StorageOptions.grpc().build().getService());
}

Expand Down Expand Up @@ -84,7 +85,7 @@ public void canary_happyPath_grpc() throws Exception {
* <li>Delete temporary bucket (Unary)
* </ul>
*/
private static void assertBehaviorOfPrimaryStorageActions(Storage storage) throws Exception {
private static void assertBehaviorOfPrimaryStorageActions(Storage storage) throws Throwable {
// create a temporary bucket
try (TemporaryBucket temporaryBucket =
TemporaryBucket.newBuilder()
Expand Down Expand Up @@ -131,6 +132,18 @@ private static void assertBehaviorOfPrimaryStorageActions(Storage storage) throw
() -> assertThat(actual.get(1).getContent()).isEqualTo(bytes),
() -> assertThat(deletes.get(0)).isTrue(),
() -> assertThat(deletes.get(1)).isTrue());
} catch (Throwable e) {
String hintMessage =
"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";
Throwable linkageError = TestUtils.findThrowable(LinkageError.class, e);
Throwable roe = TestUtils.findThrowable(ReflectiveOperationException.class, e);
if (linkageError != null) {
throw new RuntimeException(hintMessage, linkageError);
} else if (roe != null) {
throw new RuntimeException(hintMessage, roe);
} else {
throw e;
}
}
}

Expand Down
Loading

0 comments on commit eb320e1

Please sign in to comment.