-
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
Primitive default values in specifications break the object instantiation #4530
Comments
@shawkins the change looks promising but I can'z get the master to be build with all Tests. So I can't proof the correctness. Failures: Expecting |
That shouldn't be related to this pr, there's #4485 to address that test error - I'm not sure why that was closed though. |
@shawkins okay build complete project with skipTest and afterwards just build test of java-generator test worked for me. |
private String duration = io.fabric8.kubernetes.client.utils.Serialization.unmarshal(""100"", String.class); is able to be executed. |
Is there a workaround for this while we wait for a fix to be delivered? |
@adriansuarez I cannot think about any, unfortunately ... as we start to merge PRs you might be able to use the |
@andreaTP: Thank you. I've actually been working off of 51c3be8beb7a6d59beade631c912a26c18277ee4 and using the java-gen tool directly, which works. I guess I can update the commit we're pinned at when your PR is merged, and wait for the next release if we want to use the Maven plugin to do code generation. |
Hello, Tested new version 6.3.0 most default version working now, beside enumerations are not; created issue #4674. |
Enumerations are working with 6.3.1 👍 |
Thanks for the feedback @mteubner ! |
Describe the bug
Requested situation of Issue #3869 and fix on Task
#3817 lead to a situation where primitive default values in specs lead to generated classes which can't be istantiated.
Caused by: java.lang.ClassCastException: class java.lang.String cannot be cast to class java.util.Map (java.lang.String and java.util.Map are in module java.base of loader 'bootstrap')
[INFO] at io.fabric8.kubernetes.client.utils.Serialization.unmarshal(Serialization.java:237)
Fabric8 Kubernetes Client version
6.2.0
Steps to reproduce
Change for instance https://github.com/fabric8io/kubernetes-client/blob/master/java-generator/it/src/it/enum-ser-deser/src/test/resources/cert-manager.crds.1.7.1.yaml and add default value to
spec
properties:
description: Desired state of the CertificateRequest resource.
duration:
type: string
default: "100"
Execute "mvn clean verify -Dinvoker.test=enum-ser-deser"
See unmarshall exception during tests.
Generated code for the object flield can not be created, because primitive object is not json.
Same behaviour for integers or enumerations.
Expected behavior
Primitive objects may not need io.fabric8.kubernetes.client.utils.Serialization.unmarshal
It would be nice to generate Classes that can be initialized.
Runtime
other (please specify in additional context)
Kubernetes API Server version
1.24
Environment
Windows
Fabric8 Kubernetes Client Logs
Additional context
No additional requirements other then maven and change of one specification file.
The text was updated successfully, but these errors were encountered: