Reputation: 876
I have simple serializer with Jaskcon
public class NullSerializer extends JsonSerializer<Object> {
public void serialize(Object value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException {
jgen.writeString("");
}
}
After Compiling this code Java throws Error
Error:java: java.lang.StackOverflowError
I am using this dependency
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.5.1</version>
</dependency>
Any ideas ?
Upvotes: 0
Views: 1102
Reputation: 9706
Works perfectly well for me:
public class Main {
static class NullSerializer extends JsonSerializer<Object> {
public void serialize(Object value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException {
jgen.writeString("");
}
}
public static void main(String[] args) throws Exception {
ObjectMapper m = new ObjectMapper();
SimpleModule module = new SimpleModule();
module.addSerializer(Object.class, new NullSerializer());
m.registerModule(module);
System.out.println(m.writeValueAsString(
Arrays.asList(true, 1, "String", new HashMap())
)); //prints "", while without registerModule - [true,1,"String",{}]
}
}
I would look somewhere else.
For one, check your Xss for Maven. Should be at least -Xss256k
, maybe you will need more, or even better, leave it default at 1MB, because compiler uses stack differently than Java and sometimes puts structures on the stack.
I hope you are not using GWT, because if your code got exposed to GWT compiler, it would be a typical response in this situation.
And the least likely event would be that you found a genuine bug in the compiler.
Try using --debug
option with Maven, maybe it will show more info.
Upvotes: 1