Skip to content
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

Fix duplicate enum constant in java generator #5611

Merged
merged 1 commit into from
Nov 27, 2023

Conversation

iocanel
Copy link
Member

@iocanel iocanel commented Nov 25, 2023

Context: Trying to create KubeVirt model from CRDs. I am hitting an error as it seems that enum constants defined in the CRD are added twice.

This pull request changes JEnum to use Set instead of List to prevent any chance of having dublicate enum constants.

@iocanel iocanel requested review from andreaTP and manusa and removed request for manusa, sunix, shawkins, oscerd and rohanKanojia November 25, 2023 09:41
@andreaTP
Copy link
Member

Can you share the actual error, or, better, a reproducer for the issue?

This seems to be an effect of something else going wrong, not the root cause. Do we have duplicated fields in the CRD after the name sanitization?

@iocanel
Copy link
Member Author

iocanel commented Nov 26, 2023

Regardless of where is the root cause, it does make sense to use a Set instead of List for the obvious reasons.

Regarding a reproducer:
This repository: https://github.com/iocanel/quarkus-kubevirt-client
When built using: mvn clean install -Pgenerate-model can reproduce the issue.
The code generator will work, but will produce invalid code (that contains dublicate enum constants) and therefore will cause compilation to fail.

@rohanKanojia rohanKanojia changed the title Fix dublicate enum constant in java generator Fix duplicate enum constant in java generator Nov 27, 2023
@andreaTP
Copy link
Member

Regardless of where is the root cause, it does make sense to use a Set instead of List for the obvious reasons.

I agree, but I would really like to understand the underlying root cause before hiding it with this change.

@andreaTP
Copy link
Member

Copy link
Member

@andreaTP andreaTP left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that the upstream bug has been solved here:
kubevirt/cluster-network-addons-operator#1748

I'm good with those changes, thanks for reporting @iocanel

@manusa manusa added this to the 6.10.0 milestone Nov 27, 2023
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

100.0% 100.0% Coverage
0.0% 0.0% Duplication

warning The version of Java (11.0.21) you have used to run this analysis is deprecated and we will stop accepting it soon. Please update to at least Java 17.
Read more here

@manusa manusa merged commit 0f9a445 into fabric8io:main Nov 27, 2023
19 of 20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants