boonproject / boon

Simple opinionated Java for the novice to expert level Java Programmer. Low Ceremony. High Productivity.
http://richardhightower.github.io/site/Boon/Welcome.html
Apache License 2.0
520 stars 102 forks source link

Boon cannot deserialize negative numbers #357

Closed codemonstur closed 8 years ago

codemonstur commented 8 years ago
import io.advantageous.boon.json.JsonFactory;
import io.advantageous.boon.json.ObjectMapper;
import org.junit.Test;

public class TestSerialization {
    private final ObjectMapper mapper = JsonFactory.create();

    class ThisIsAnInt {
        public int value = -1062731519;
    }

    @Test
    public void testDeserialize() {
        String json = mapper.toJson(new ThisIsAnInt());
        mapper.fromJson(json, ThisIsAnInt.class);
    }
}

MESSAGE: fieldName value of class class nl.spero.hostrank.classifier.test.TestSerialization$ThisIsAnInt had issues for value -1062731519 for field FieldInfo [name=value, type=int, parentType=class nl.spero.hostrank.classifier.test.TestSerialization$ThisIsAnInt]

 CAUSE io.advantageous.boon.core.Exceptions$SoftenedException :: not an int

ROOT CAUSE MESSAGE: not an int 
     This happens around this area in your code.
          io.advantageous.boon.core.reflection.MapperSimple.fromValueMap(MapperSimple.java:1134)
          io.advantageous.boon.json.JsonMappingParser.finalExtract(JsonMappingParser.java:210)
          io.advantageous.boon.json.JsonMappingParser.parse(JsonMappingParser.java:202)
          io.advantageous.boon.json.implementation.ObjectMapperImpl.readValue(ObjectMapperImpl.java:68)
          io.advantageous.boon.json.implementation.ObjectMapperImpl.fromJson(ObjectMapperImpl.java:279)
codemonstur commented 8 years ago

Looks like something went wrong during testing. I initially used version 0.6.1 to run this test where it failed. Then I updated to the latest 0.6.6 and got the same error. However, I cannot reproduce it now. I tried some other versions and can get the code to fail reliably for version 0.6.3 and lower. But no longer in the latest version. Perhaps there was a caching error of some kind on my side. Apologies.

RichardHightower commented 8 years ago

Thanks. I am glad this is fixed. Let me know if you can reproduce it.