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 StackOverflow on cyclic references involving collections. #4512

Merged
merged 1 commit into from Nov 16, 2022

Conversation

xRodney
Copy link
Contributor

@xRodney xRodney commented Oct 20, 2022

Description

The logic in ClassDependenciesVisitor was prone to SO when there were cyclic references in the schema. This should fix it, and the tests are still passing, so hopefully it is safe.

Fixes #4510

TBH, I do not fully understand the purpose of ClassDependenciesVisitor, I realize it it used in tests and maybe when someone would want to include the generator in their own code? I would be grateful for some pointers.

It appears that it exists mostly to facilitate conditional hot reload when used with quarkus, as implemented here https://github.com/quarkiverse/quarkus-operator-sdk/blob/main/core/deployment/src/main/java/io/quarkiverse/operatorsdk/deployment/OperatorSDKProcessor.java#L187

This still works with my changes, see my comment below.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • Feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change
  • Chore (non-breaking change which doesn't affect codebase;
    test, version modification, documentation, etc.)

Checklist

  • Code contributed by me aligns with current project license: Apache 2.0
  • I Added CHANGELOG entry regarding this change
  • I have implemented unit tests to cover my changes
  • I have added/updated the javadocs and other documentation accordingly
  • No new bugs, code smells, etc. in SonarCloud report
  • I tested my code in Kubernetes
  • I tested my code in OpenShift

@xRodney xRodney force-pushed the bugfix/cyclic-references-again branch 2 times, most recently from 03730a5 to 56cf440 Compare October 20, 2022 08:52
@andreaTP
Copy link
Member

Hey @xRodney ! Thanks for this follow-up!

Arrived at this point do you think it's worth adding an integration test using the RealmRepresentation from the published jar keycloak-models?

Regarding your question about ClassDependenciesVisitor @metacosm should be the best person to answer.

@xRodney xRodney force-pushed the bugfix/cyclic-references-again branch from 56cf440 to 4a182f7 Compare October 20, 2022 11:33
@xRodney
Copy link
Contributor Author

xRodney commented Oct 20, 2022

@andreaTP, I have added keycloak test in the latest commit, just to see how that would look like.
I'll leave it up to you and the team to decide if it is a good idea.

@andreaTP
Copy link
Member

Thanks, a lot @xRodney ! At least, this guarantees us that we are at the end of the tunnel 🙂 super glad you picked it up!

Let @manusa and @rohanKanojia decide whether they think adding this hard dependency to test is a good idea or not.
Meanwhile, this guarantees us some kind of confidence this is going to work 🥳

@xRodney xRodney force-pushed the bugfix/cyclic-references-again branch 2 times, most recently from a7cced0 to 80cf4ad Compare October 21, 2022 07:16
@xRodney xRodney marked this pull request as ready for review October 21, 2022 08:28
@xRodney xRodney force-pushed the bugfix/cyclic-references-again branch from 80cf4ad to 0a80f73 Compare October 29, 2022 20:28
@xRodney
Copy link
Contributor Author

xRodney commented Nov 1, 2022

Hi, @manusa and @rohanKanojia, do you have any opinion on this?
If you feel this needs a deeper discussion, I would be happy to extract the Keycloak tests to a separate PR and just fix the bug here. It's up to you.

@xRodney
Copy link
Contributor Author

xRodney commented Nov 3, 2022

Okay, so regarding my original uncertainty regarding the purpose of ClassDependenciesVisitor:
Iit appears that it exists mostly to facilitate conditional hot reload when used with quarkus, as implemented here https://github.com/quarkiverse/quarkus-operator-sdk/blob/main/core/deployment/src/main/java/io/quarkiverse/operatorsdk/deployment/OperatorSDKProcessor.java#L187
Originally, I was testing it as a raw java operator, but with quarkus it really shines (when it does not SO, I mean :D )
So I booted up quarkus-operator-sdk and replaced dependencies with my changes from this PR, and hot reload seems to work as expected. So I think we should be fine.

About Keycloak dependency:
Since there seems to be not much interest, I propose to exclude it to a separate PR. I really wish that the bugfix makes it to the 6.3 release, and I feel that the (lack of) discussion about a test would unnecessarily delay the merge.

@xRodney xRodney force-pushed the bugfix/cyclic-references-again branch from 0a80f73 to 849d45b Compare November 4, 2022 14:52
@manusa
Copy link
Member

manusa commented Nov 16, 2022

Hi, sorry for the delayed response, it's been 4 long hectic weeks and I'm now catching up with everything

About Keycloak dependency:

Yes, it's better we discuss this separately. In general it's better to proceed this way since otherwise things get delayed

Copy link
Member

@manusa manusa left a comment

Choose a reason for hiding this comment

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

code-wise looks good.
🙏 Andrea/Chris check if feature-wise it's OK.

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.

LGTM, thanks for the separate PR on the Keycloak CR 👍

@manusa manusa force-pushed the bugfix/cyclic-references-again branch from 849d45b to 0975eae Compare November 16, 2022 11:30
@sonarcloud
Copy link

sonarcloud bot commented Nov 16, 2022

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

94.4% 94.4% Coverage
0.0% 0.0% Duplication

@manusa manusa added this to the 6.3.0 milestone Nov 16, 2022
@manusa manusa merged commit 4ab4dbb into fabric8io:master Nov 16, 2022
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.

Stack overflow on recursive types (again)
3 participants