From 2dd4726f7b6dd4522bece57444f144f500f1381a Mon Sep 17 00:00:00 2001 From: Foivos Zakkak Date: Thu, 25 Mar 2021 01:35:23 +0200 Subject: [PATCH] Runtime initialize grpc class using j.u.Random --- .../io/quarkus/grpc/deployment/GrpcClientProcessor.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/extensions/grpc/deployment/src/main/java/io/quarkus/grpc/deployment/GrpcClientProcessor.java b/extensions/grpc/deployment/src/main/java/io/quarkus/grpc/deployment/GrpcClientProcessor.java index b4eca2f58b59a..adb67d9fe1e89 100644 --- a/extensions/grpc/deployment/src/main/java/io/quarkus/grpc/deployment/GrpcClientProcessor.java +++ b/extensions/grpc/deployment/src/main/java/io/quarkus/grpc/deployment/GrpcClientProcessor.java @@ -32,6 +32,7 @@ import io.quarkus.deployment.annotations.BuildStep; import io.quarkus.deployment.builditem.FeatureBuildItem; import io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBuildItem; +import io.quarkus.deployment.builditem.nativeimage.RuntimeInitializedClassBuildItem; import io.quarkus.gizmo.MethodCreator; import io.quarkus.gizmo.MethodDescriptor; import io.quarkus.gizmo.ResultHandle; @@ -175,6 +176,12 @@ void registerSslResources(BuildProducer resourceBu registerResourcesForProperties(config, resourceBuildItem, TRUST_STORE_PATTERN, CERTIFICATE_PATTERN, KEY_PATTERN); } + @BuildStep + void runtimeInitialize(BuildProducer producer) { + // io.grpc.internal.RetriableStream uses j.u.Ramdom, so needs to be runtime-initialized + producer.produce(new RuntimeInitializedClassBuildItem("io.grpc.internal.RetriableStream")); + } + private void generateChannelProducer(MethodCreator mc, GrpcServiceBuildItem svc) { ResultHandle name = mc.load(svc.getServiceName()); ResultHandle result = mc.invokeStaticMethod(CREATE_CHANNEL_METHOD, name);