Skip to content
This repository has been archived by the owner on Nov 5, 2019. It is now read-only.

Commit

Permalink
Likely fixed #33; still need to verify with jvm-serializers perf test
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Sep 28, 2013
1 parent 7a5ecb1 commit f147246
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 19 deletions.
2 changes: 2 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ com.fasterxml.jackson.module.afterburner.util
,com.fasterxml.jackson.databind.util
,org.objectweb.asm;resolution:=optional
</osgi.import>
<!--
<osgi.private>com.fasterxml.jackson.module.afterburner.asm</osgi.private>
-->
</properties>

<dependencies>
Expand Down
12 changes: 7 additions & 5 deletions release-notes/VERSION
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
Project: jackson-module-afterburner
Version: 2.2.3 (23-Aug-2013)
Version: 2.3.0 (xx-Oct-2013)

#33: `SuperSonicBeanDeserializer` not working (missing optimization)

------------------------------------------------------------------------
=== History: ===
------------------------------------------------------------------------

#9: Ensure that `@JsonUnwrapped` handling still works
#23: Support deserialization of interface types
Expand All @@ -9,10 +15,6 @@ Version: 2.2.3 (23-Aug-2013)
#29: NON_DEFAULT inclusion setting ignored by primitive writers
(reported by rwbergstrom@github)

------------------------------------------------------------------------
=== History: ===
------------------------------------------------------------------------

2.2.2 (27-May-2013)

#20: Protect Afterburner against IllegalAccessError and SecurityException
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public BeanDeserializerBuilder updateBuilder(DeserializationConfig config,
// also: may want to replace actual BeanDeserializer as well? For this, need to replace builder
// (but only if builder is the original standard one; don't want to break other impls)
if (_useCustomDeserializer && builder.getClass() == BeanDeserializerBuilder.class) {
return new CustomDeserializerBuilder(builder);
return new SuperSonicDeserializerBuilder(builder);
}
return builder;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import com.fasterxml.jackson.core.*;
import com.fasterxml.jackson.core.io.SerializedString;

import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.databind.deser.*;
import com.fasterxml.jackson.databind.util.NameTransformer;
Expand Down Expand Up @@ -101,6 +100,24 @@ public void resolve(DeserializationContext ctxt)
_orderedProperties = props.toArray(new SettableBeanProperty[props.size()]);
}

@Override
public Object deserialize(JsonParser jp, DeserializationContext ctxt)
throws IOException, JsonProcessingException
{
if (!_vanillaProcessing || _objectIdReader != null) {
// should we ever get here? Just in case
return super.deserialize(jp, ctxt);
}
JsonToken t = jp.getCurrentToken();
// common case first:
if (t != JsonToken.START_OBJECT) {
return _deserializeOther(jp, ctxt, t);
}
t = jp.nextToken();
// Inlined version of:
return deserializeFromObject(jp, ctxt);
}

// much of below is cut'n pasted from BeanSerializer
@Override
public final Object deserialize(JsonParser jp, DeserializationContext ctxt, Object bean)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@

import java.util.*;

import com.fasterxml.jackson.databind.JsonDeserializer;
import com.fasterxml.jackson.databind.deser.*;

public class CustomDeserializerBuilder extends BeanDeserializerBuilder
public class SuperSonicDeserializerBuilder extends BeanDeserializerBuilder
{
public CustomDeserializerBuilder(BeanDeserializerBuilder base)
public SuperSonicDeserializerBuilder(BeanDeserializerBuilder base)
{
super(base);
}

@Override
public BeanDeserializer build()
public JsonDeserializer<?> build()
{
BeanDeserializer deser = (BeanDeserializer) super.build();
// only create custom one, if existing one is standard deserializer;
Expand Down
18 changes: 9 additions & 9 deletions src/test/java/perftest/TestDeserializePerf.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,34 +11,34 @@ public class TestDeserializePerf
{
public final static class Bean
{
public int a, b, c, d;
public int e, f, g, h;
public int a, b, c123, d;
public int e, foobar, g, habitus;

public Bean setUp() {
a = 1;
b = 999;
c = -1000;
c123 = -1000;
d = 13;
e = 6;
f = -33;
foobar = -33;
g = 0;
h = 123456789;
habitus = 123456789;
return this;
}

public void setA(int v) { a = v; }
public void setB(int v) { b = v; }
public void setC(int v) { c = v; }
public void setC(int v) { c123 = v; }
public void setD(int v) { d = v; }

public void setE(int v) { e = v; }
public void setF(int v) { f = v; }
public void setF(int v) { foobar = v; }
public void setG(int v) { g = v; }
public void setH(int v) { h = v; }
public void setH(int v) { habitus = v; }

@Override
public int hashCode() {
return a + b + c + d + e + f + g + h;
return a + b + c123 + d + e + foobar + g + habitus;
}
}

Expand Down

0 comments on commit f147246

Please sign in to comment.