-
Notifications
You must be signed in to change notification settings - Fork 3k
Description
Describe the bug
Given a quarkus-resteasy-reactive JAX-RS resource, when an endpoint returns a response that includes an entity with a field of type Enum
which has an attached value, response includes the value of the Enum in jvm mode whereas in native mode response includes the name of the Enum.
Expected behavior
Native mode of the application should also return the enum variable same as the behaviour in jvm mode.
Actual behavior
As opposed to jvm mode, native mode of the application returns the enum name.
How to Reproduce?
Reproducer repo: https://github.com/Mert-Z/quarkus-native-enum-value-serialisation-issue
Verify succeeds in jvm mode (i.e mvn clean verify -U
)
Verify fails in native mode (i.e mvn clean verify -U -Pnative
)
Here is the Enum definition;
public enum TestEnum {
VALUE_1("Value 1");
private String value;
TestEnum(String value) {
this.value = value;
}
public static TestEnum fromString(String s) {
for (TestEnum b : TestEnum.values()) {
if (Objects.equals(Objects.toString(b.value), s)) {
return b;
}
}
throw new IllegalArgumentException("Unexpected string value '" + s + "'");
}
@Override
@JsonValue
public String toString() {
return String.valueOf(value);
}
@JsonCreator
public static TestEnum fromValue(String value) {
for (TestEnum b : TestEnum.values()) {
if (b.value.equals(value)) {
return b;
}
}
throw new IllegalArgumentException("Unexpected value '" + value + "'");
}
}
Response entity;
@RegisterForReflection
public class GreetingResponse {
private TestEnum testEnum;
public GreetingResponse(TestEnum testEnum) {
this.testEnum = testEnum;
}
@JsonProperty("testEnum")
public TestEnum getTestEnum() {
return testEnum;
}
@JsonProperty("testEnum")
public void setTestEnum(TestEnum testEnum) {
this.testEnum = testEnum;
}
}
Response body in jvm mode;
{"testEnum":"Value 1"}
Response body in native mode;
{"testEnum":"VALUE_1"}
Output of uname -a
or ver
No response
Output of java -version
Java version: 17.0.5, vendor: GraalVM Community
GraalVM version (if different from Java)
GraalVM CE 22.3.0 (build 17.0.5+8-jvmci-22.3-b08)
Quarkus version or git rev
2.16.5.Final
Build tool (ie. output of mvnw --version
or gradlew --version
)
Apache Maven 3.8.6
Additional information
No response