-
Notifications
You must be signed in to change notification settings - Fork 32
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
Skip serialization of groovy.lang.MetaClass
values to avoid StackOverflowError
#93
Comments
I think it is possible for users to implement something like this, similar to Now, this could make useful addition to If anyone wanted to provide a PR for addition here, I'd be happy to help to see if JDK baseline can be improved. |
It's possible to check if an element is annotated with |
True, there are ways around that. And although it's bit brittle (relying on names) it might be fine. Oh. However... there is a good reason for NOT adding dependency to that class at all: it will bring big non-core Beans module for JDK 9+. So maybe by-name check is the proper way to go. So, I'd be open for addition if anyone has time to work on PR. I would also suggest adding a feature to enable/disable recognition of this annotation: I fully expect someone somewhere to NOT want ignoral. This based on adding similar features in the past. |
Quick note: JDK 8 has been baseline since 2.14 (as per #95) so this could just be added now. |
I think this would be good thing to have PR for; marking as such. |
Okay, this might sound a bad programming practice, but I noticed skipping over groovy MetaClassImpl to be a better alternative than checking for annotations. (I tried first & didnt work).
but since this is not optimal solution , i would like to hear your thoughts @cowtowncoder ? Do we really require groovy class metadata? |
I think core So I think a PR for such patch would make sense. One thing that'd be great would be unit test showing this in action, but not sure how easy that'd be to do. |
@chashnikov Our attempts to reproduce the issue with So some help would be needed to reproduce the issue: fix itself should be relatively easy after that. |
groovy.lang.MetaClass
values to avoid StackOverflowError
Try serializing empty Groovy class using Groovy 3.0.9 and jackson-jr-objects:2.13.1:
It'll fail with
StackOverflowError
:This happens because every class file generated from Groovy class contains
getMetaClass
method, which contains data with meta-information with cyclic references inside. The method is marked with@java.beans.Transient
annotation, so if serialization automatically skips such properties, the problem will be solved.The text was updated successfully, but these errors were encountered: