-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Native gRPC application: missing method "valueOf" #24510
Comments
Additional information: I found that the problem did not occur if I annotated the inner enum class with public final class LanguageSpec
extends com.google.protobuf.GeneratedMessageV3
implements LanguageSpecOrBuilder {
...
@RegisterForReflection // <=== added this ===
public enum Language
implements com.google.protobuf.ProtocolMessageEnum {
ENGLISH(0),
FRENCH(1),
SPANISH(2),
UNRECOGNIZED(-1),
;
public static final int ENGLISH_VALUE = 0;
public static final int FRENCH_VALUE = 1;
public static final int SPANISH_VALUE = 2;
public final int getNumber() {
if (this == UNRECOGNIZED) {
throw new java.lang.IllegalArgumentException(
"Can't get the number of an unknown enum value.");
}
return value;
}
@java.lang.Deprecated
public static Language valueOf(int value) {
return forNumber(value);
}
public static Language forNumber(int value) {
switch (value) {
case 0: return ENGLISH;
case 1: return FRENCH;
case 2: return SPANISH;
default: return null;
}
}
... |
Since the gRPC code is generated and should not be modified, I tried registering the problematic inner class using another class, it is did successfully work-around the missing method problem: package net.example;
import io.quarkus.runtime.annotations.RegisterForReflection;
import net.example.grpctest.LanguageSpec;
@RegisterForReflection(targets = { LanguageSpec.Language.class })
public class GrpcInnerClassWorkAround {
} |
The issue is that we do not register the enum class. It should be done automatically. |
Protobuf enums generate enum classes. Fortunately, we can locate them with Jandex using the ProtocolMessageEnum interface, as the generated enums implement this interface. Fix quarkusio#24510.
Protobuf enums generate enum classes. Fortunately, we can locate them with Jandex using the ProtocolMessageEnum interface, as the generated enums implement this interface. Fix quarkusio#24510. (cherry picked from commit 612348e)
Protobuf enums generate enum classes. Fortunately, we can locate them with Jandex using the ProtocolMessageEnum interface, as the generated enums implement this interface. Fix quarkusio#24510. (cherry picked from commit 612348e)
Protobuf enums generate enum classes. Fortunately, we can locate them with Jandex using the ProtocolMessageEnum interface, as the generated enums implement this interface. Fix quarkusio#24510. (cherry picked from commit 612348e)
Reproduced on dependencies in owned generated enum protobuf-maven-plugin is it possible somehow to solve the problem without reflection-config.json |
Hello, we stumbled upon the same issue when we were logging out the part of proto generated object, so when the
The protos were generated with protobuf 3.21.12. The The |
Describe the bug
I am seeing an issue when I have a gRPC message with an inner-enum. If I run the application in dev mode or from a JAR, all is fine, but when I build and run as a native app, an exception is thrown complaining that the valueOffor the enum is missing. I have checked the generated code and the method is actually present. I did notice that the method was annotated with @deprecated (not sure if this is relevant).
This occurs with both the gRPC server application and gRPC client application.
Expected behavior
Should run without any complaints.
Actual behavior
How to Reproduce?
quarkus-grpc-issue.tar.gz
tar -xzf quarkus-grpc-issue.tar.gz
mvn package -Pnative
./target/grpc-test-1.0.0-runner
Output of
uname -a
orver
Linux rocky.example.net 4.18.0-305.10.2.el8_4.x86_64 #1 SMP Tue Jul 20 20:34:55 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
Output of
java -version
openjdk version "11.0.13" 2021-10-19 OpenJDK Runtime Environment Temurin-11.0.13+8 (build 11.0.13+8) OpenJDK 64-Bit Server VM Temurin-11.0.13+8 (build 11.0.13+8, mixed mode)
GraalVM version (if different from Java)
quay.io/quarkus/ubi-quarkus-native-image:21.3-java11
GraalVM 21.3.1 Java 11 CE (Java Version 11.0.14+9-jvmci-21.3-b09)
Quarkus version or git rev
Quarkus 2.7.5.Final
Build tool (ie. output of
mvnw --version
orgradlew --version
)Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: /opt/maven
Java version: 11.0.13, vendor: Eclipse Adoptium, runtime: /opt/jdk-11.0.13+8
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "4.18.0-305.10.2.el8_4.x86_64", arch: "amd64", family: "unix"
Additional information
No response
The text was updated successfully, but these errors were encountered: