-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
CRD Generator not filtering ENUM$VALUES synthetic field #5228
Comments
The bug might be legit, have you attempted to explicitly add |
Where would I add that on an enum?
The stack overflow post also complains about the unpredictable nature of seeing both representations. |
If I for example add an explicit ENUM$VALUES field or enum value with a jsonignore, then when this issue is occurring another A couple of additional observations:
|
Thanks a lot for the additional information @shawkins ! I'll take a closer look into this early next week, I hope that In the test suite we are already generating the Realm import CRD from Keycloak, have you already verified if the bug reproduces locally to this codebase? |
Unfortunately it does not - it probably should to then not use starting with $ as a filter. However it does convey that the field is static and private - that should not be included with the rest of the enums. Adding a filter like:
Will address this specific case. It does bring up that only simple enums are supported - if you also include state in the enum, then it will be mistakenly included in the schema:
causes rating to show up as an enum value. Maybe only public static fields should be included (it is of course possible with jackson to change the serialization of enums https://www.baeldung.com/jackson-serialize-enums but none of that is supported either).
I was able to reproduce it eventually just with the JokeRequestSpec - ENUM$VALUES showed up as an enum value. However I still don't know what causes that. Trying different jres, etc., doesn't seem to guarentee that it will happen - it didn't initially happen when testing the SchemaSwap either. Whatever causes it, it is known as a possibility in the jdk source: https://github.com/openjdk/jdk11u/blob/1000b1c0074af4b954c5f210d1684b5623e9723b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.common/src/org/graalvm/compiler/core/common/spi/JavaConstantFieldProvider.java#L131 |
This issue might have the same solution as: #4225 |
@andreaTP for now let's combine the filtering from that pr with the public static requirement:
That will leave the corner case of a public static field on the enum that is typed the same as the enum (should be extremely rare). The only way to account for that is to expand sundrio to expose Field.isEnumConstant() - since that's such a corner case though I'd vote on adding the filtering now rather than waiting for the sundrio fix. |
@shawkins I agree that we need to get a fix for this.
This is the only detail I disagree with since a Meanwhile, if you want to submit the proposed workaround I'll accept it to make sure we improve for the next release. |
This would have to be expressed as:
Using a method would be fine because we're only looking at the fields.
#4230 has been updated. |
Marking resolved by #4230 - there will be another improvement after sundrio/sundrio#389 |
Describe the bug
There seems to be some inconsistency with the VM reflection reporting $VALUES vs ENUM$VALUES - https://stackoverflow.com/questions/46924470/java-enums-enumvalues-or-values
If ENUM$VALUES is reported - and I don't quite see why it is as the same jre gives me different behavior at times - then it won't be filtered by the logic looking for a name starting with a $ -
kubernetes-client/crd-generator/api/src/main/java/io/fabric8/crd/generator/AbstractJsonSchema.java
Line 668 in 683336b
Fabric8 Kubernetes Client version
6.6.2
Steps to reproduce
Not quite sure the behavior seems inconsistent.
Expected behavior
That the VALUES field will be omitted regardless.
Ideally ClassToTypeDef would check / filter synthetic properties rather than just relying upon the $ convention.
Runtime
other (please specify in additional context)
Kubernetes API Server version
other (please specify in additional context)
Environment
Linux
Fabric8 Kubernetes Client Logs
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: