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
Serializing org.slf4j.Logger results in StackOverflowError #305
Comments
hi @nimo23, are you sure there is not a circular dependency reference somewhere in your bean object? Can you share the contents of your java class? If I try the following code, it works as expected: public class AGGMain {
public static class Bar {
// no properties here
}
private static final Jsonb jsonb = JsonbBuilder.create();
public static void main(String args[]) throws Exception {
Bar empty = new Bar();
System.out.println(jsonb.toJson(empty)); // prints: {}
}
} |
I found the error, it's the
I get this stacktrace which differs a little from the above:
If I delete the If I use |
normally |
Imagine defining a logger within an abstract class and each extended class has a logger instance with its class name (getClass()), this is common. Also, in 3rd party libs, a Logger can be defined without using static (for example, within an abstract class) and we cannot use Should not be matter , if static logger or not..yasson should not try to (de)serialize a logger instance. |
I tried this out locally and got the same StackOverflowError. While I still think non-static Loggers is bad practice, Yasson should tolerate this scenario better than it currently does. |
Yes, that would be good. Btw, could you please look at #306 again and think about to re-open. Would be great. |
Shouldn't be transient the logger instance?: Then you can reuse the logger in subclasses, and the json parser should skip the log from serialization. |
this issue should now be resolved by PR #359 |
With jackson I get the following json-string as a result of an empty bean with the setting
mapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS)
{ }
With yasson I get this stacktrace:
I guess, the stacktrace is thrown because there are no accessors for that bean. In my opinion, if no accessors are found
{ }
should be returned for that bean instead ofStackOverflowError
The text was updated successfully, but these errors were encountered: