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

moving private JacksonObjectMapper into companion object to establish compatibility with CGLIB proxying #694

Conversation

mwftapi
Copy link
Contributor

@mwftapi mwftapi commented Oct 13, 2021

Pull Request type

  • Bugfix
  • Feature
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Other (please describe):

Changes in this PR

Follow-up on PR#275 and PR#428 which were opened by my colleague @lucatk.

Since with version v4.5.1 a fix was introduced to Avoid instantiating Jackson mappers per request we are encountering again the issue that the @RestControllers DgsRestSchemaJsonController and DgsSSESubscriptionHandler are not working when provided as a CGLIB proxied bean in our enterprise application since their mappers are null as soon as they are provided as a CGLIB proxied bean.

This PR moves the mapper class fields into companion objects (thanks, @berngp). This should not affect any business logic or the like. Since these classes are already documented to actually be inner APIs and extending should not be performed, i don't see the need for any more communication regarding this issue on those classes.

This PR was opened with the understanding that this issue was addressed in the past as well as based on the caring and understanding statement from @paulbakker on one of the related, previous PRs.

Alternatives considered

What i could see in the future is the usage of the kotlin-allopen plugin especially its kotlin-spring plugin that focuses on opening just the classes that are annotated with selected org.springframework annotations when compiling.

This might make it easier to follow the kotlin paradigms without interfering with compatibility regarding established java ecosystem frameworks and approaches.

But this will not remove the need to communicate that openly provided classes should not be extended since they are open for CGLIB compatibility and not being actual public APIs of this framework.

I tried to incorporate the plugin into this project but i have not much expertise in kotlin, gradle and this projects build setup and i don't think me as a extern contributor would have a chance to incorporate it without breaking a lot of things.

Acknowledgement

Thank you for considering this PR and thank you for this amazing framework which tremendously helps to provide a solid GraphQL API with minimal effort when utilized in a Spring Boot Application context!

Copy link
Contributor

@berngp berngp left a comment

Choose a reason for hiding this comment

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

The mappers can be moved to a companion object, kept private, and not interfere with your cglib proxying.

@mwftapi mwftapi force-pushed the fix/reopen-jackson-object-mappers-on-rest-controllers branch from b7e041e to 1502575 Compare October 14, 2021 08:15
@mwftapi mwftapi changed the title opening rest controllers jackson object mappers in order to provide interoperability with CGLIB proxied beans moving private JacksonObjectMapper into companion object to establish compatibility with CGLIB proxying Oct 14, 2021
@mwftapi mwftapi requested a review from berngp October 14, 2021 08:17
@berngp
Copy link
Contributor

berngp commented Oct 14, 2021

Thanks for making the changes.

@berngp berngp merged commit d9e83b3 into Netflix:master Oct 14, 2021
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.

None yet

2 participants