Comments (16)
To reproduce, I just need a class class A<T extends A>
annotated with @JsonIgnoreType
and a second class having class A in a field ?
I'm not sure what you can do. I normally don't parse children of Objet unless they are explicitly whitelisted. Which version do you use ? I had a bug on Serializable class which is fixed in the current snapshot.
from gwt-jackson.
Yes, we have different self-parameterized classes, but also java's Enum can be listed as a cause of stack overflow, as Enum is in fact Enum<E extends Enum<E>>.
We have tried to use custom serializers for those unbounded generic classes (like Abc), but it seems that gwt-jackson first analyzes the class hierarchy, before starting to generate the mappers and using custom serializers.
I have put some System.out.println into JTypeName.java, to log the visited classes, to trace what is happening.
And as said, just the fact that some problematic class is on the classpath, and never used for the serialization, causes stack overflow, when matching Object or fields. This means that if I have some java bean, with some Abc field, every known class will be processed as a possible candidate for "?". Because I saw many GWT UI classes, like ListBox etc, which are never serialized, not even referenced by the serialization classes, but were listed in the console.
I must mention, that this happens with GWT unit tests. Currently we cannot try this in the normal hosted mode in the browser.
from gwt-jackson.
The annotation @JsonIgnoreType is not even necessary to reproduce the problem. I just think that gwt-jackson should stop processing the class hierarchy when it finds a class, annotated with @JsonIgnoreType.
from gwt-jackson.
I am using the latest official version, 0.9.0.
from gwt-jackson.
Example:
public class Abc<T> {
}
public class SomeBean {
public Abc<?> abc;
}
This will match every known class as a type for Abc. So it will process all known classes, until some problematic one is found and causes stack overflow. So some class A<T extends A> will be processed, even if not explicitly referenced anywhere.
from gwt-jackson.
What hierarchy do you have on your self-parameterized classes ?
I can reproduce the stackoverflow with :
public static class Toto {
public Tata<?> huhu;
}
public static class Tata<T extends Tata> {
public T tutu;
}
But if I add the @JsonIgnoreType
, the error disappear.
from gwt-jackson.
Managed to reproduce it with a supertype :
public static class Toto {
public Tutu tutu;
}
public static class Tutu {
}
@JsonIgnoreType
public static class Tata<T extends Tata> extends Tutu {
public T tata;
}
To (de)serialize Tutu
, I parse all its children to create deserializer. I guess I don't filter out type annotated with @JsonIgnoreType.
from gwt-jackson.
It should be fixed, at least the case I was able to reproduce. Can you test the snapshot ?
from gwt-jackson.
For Tata, you don't even need to extend Tutu. Just the mere fact that self-referencing Tata is in the classpath, is enough to be somehow found, causing the stack overflow. The problem with the stack overflow itself was already mentioned in another issue, here the issue is that completely unreferenced classes are processed.
I am not sure if completely unused classes are also processed, but I can guarantee that the classes, that are used somewhere (like in UI), but not in the JSON serialization logic, are still processed.
If I don't have any unbounded class or Object in the serialization logic, then only the limited number of directly referenced classes are processed.
from gwt-jackson.
Have tried with the latest master revision, but it's the same stack overflow. The stack trace is completely the same as in issue #48.
I might help if there would be some additional optional setting (in .gwt.xml), to limit the classpaths or packages where to search for the classes. Like gwtJacksonClasspaths="com.xxx.yyy;com.xxx.zzz".
from gwt-jackson.
You have the stack overflow even with the self-referencing types annotated with @JsonIgnoreType
?
I still have the stack overflow but only when the @JsonIgnoreType is not set in my test case.
from gwt-jackson.
It crashes when encountering Enum<E extends Enum<E>>, which I cannot annotate, since it's part of JRE. But will try with a mixin for Enum.
A note: we never reference Enum<?> in any of our json serializable classes.
from gwt-jackson.
No, registering a mixin with @JsonIgnoreType for Enum doesn't help. Still stack overflow.
@JsonIgnoreType
private static class EnumMixIn {
}
...
addMixInAnnotations(Enum.class, EnumMixIn.class);
from gwt-jackson.
However, with the snapshot, the classes directly annotated with @JsonIgnoreType are ignored, thanks.
from gwt-jackson.
The problem with Enum was, that many UI-only classes were parameterized with Enum, like EnumListBox<T extends Enum<?>>.
When I annotated all those problematic classes with @JsonIgnoreType, they were ignored, and the unit test succeeded. No more stack overflow.
But annotating self-parameterized interfaces doesn't work, I had to annotate all the implemented classes.
However, annotating UI classes with @JsonIgnoreType is not really nice. Registering a mixin with @JsonIgnoreType didn't work for Enum, I rather had to ignore all the classes parameterized with Enum.
Is it possible to implement such mixins?
from gwt-jackson.
It's odd it didn't work on interface, I'm normally looking for annotations on all hierarchy.
I'll look next week when I have more spare time.
from gwt-jackson.
Related Issues (20)
- No source code is available for type com.fasterxml.jackson.databind.ObjectMapper; did you forget to inherit a required module? HOT 3
- Support for java.util.Optional HOT 1
- Expected a string but was BEGIN_OBJECT at line 1 column 2 HOT 1
- Please REVERT the dependency on Jackson 2.9.*, Jackson 2.9.* is NOT compatible with GWT. HOT 2
- Support for @JsonCreator(mode = Mode.DELEGATING)
- Custom deserializer compilation error
- Getter returning Optional<T> of nullable T causing compilation error HOT 2
- GWT 2.6.1 + GwtJackson 0.15.3 HOT 3
- JsonSerializationContext.Builder override not working as expected
- Error:GWT Compiler: No source code is available for type com.fasterxml.jackson.annotation.JsonTypeInfo.As; did you forget to inherit a required module?
- JsonTypeInfo defaultImpl attribute not working HOT 1
- Update jackson dependency to 2.9.8
- Update javapoet dependency to 1.11.1
- Support for JsonFormat.Feature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE
- Annotations on Java8 default interface are ignored HOT 1
- Can't figure out the stackoverflow I am getting
- More (de)serialization customization (JsonFilter or equivalent)
- Double.NaN / NEGATIVE_INFINITY / POSITIVE_INFINITY - Numeric values must be finite, but was
- Many compile problems
- I want to deserialize a property with any type of value.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gwt-jackson.