Skip to content

Commit 3f4ac32

Browse files
committed
Merge branch '2.8'
2 parents f2b029d + 494ebce commit 3f4ac32

File tree

6 files changed

+151
-6
lines changed

6 files changed

+151
-6
lines changed

release-notes/CREDITS

+4
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,10 @@ Josh Gruenberg (joshng@github)
562562
* Reported #1403: Reference-chain hints use incorrect class-name for inner classes
563563
(2.8.4)
564564

565+
Kevin Donnelly (kpdonn@github)
566+
* Reported #1432: Off by 1 bug in PropertyValueBuffer
567+
(2.8.5)
568+
565569
Connor Kuhn (ckuhn@github)
566570
* Contributed #1341: FAIL_ON_MISSING_EXTERNAL_TYPE_ID_PROPERTY
567571
(2.9.0)

release-notes/VERSION

+4
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ Project: jackson-databind
3232
#1417: Further issues with `@JsonInclude` with `NON_DEFAULT`
3333
#1429: `StdKeyDeserializer` can erroneously use a static factory method
3434
with more than one argument
35+
#1432: Off by 1 bug in PropertyValueBuffer
36+
(reported by Kevin D)
3537
- Improvements to #1411 fix to ensure consistent `null` key handling
3638

3739
2.8.4 (14-Oct-2016)
@@ -56,6 +58,8 @@ Project: jackson-databind
5658
(reported by Josh G)
5759
#1411: MapSerializer._orderEntries should check for null keys
5860
(reported by Jörn H)
61+
#1432: Off by 1 bug in PropertyValueBuffer
62+
(reported by Kevin D)
5963

6064
2.8.3 (17-Sep-2016)
6165

src/main/java/com/fasterxml/jackson/databind/deser/impl/PropertyValueBuffer.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -274,10 +274,10 @@ public boolean assignParameter(SettableBeanProperty prop, Object value)
274274
}
275275
} else {
276276
if (!_paramsSeenBig.get(ix)) {
277+
_paramsSeenBig.set(ix);
277278
if (--_paramsNeeded <= 0) {
278279
return true;
279280
}
280-
_paramsSeenBig.set(ix);
281281
}
282282
}
283283
return false;

src/main/java/com/fasterxml/jackson/databind/deser/impl/ValueInjector.java

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
public class ValueInjector
2020
extends BeanProperty.Std
2121
{
22+
private static final long serialVersionUID = 1L;
23+
2224
/**
2325
* Identifier used for looking up value to inject
2426
*/

src/test/java/com/fasterxml/jackson/databind/deser/TestCustomValueInstDefaults.java renamed to src/test/java/com/fasterxml/jackson/databind/creators/TestCustomValueInstDefaults.java

+138-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
1-
package com.fasterxml.jackson.databind.deser;
1+
package com.fasterxml.jackson.databind.creators;
2+
3+
import java.io.IOException;
24

35
import com.fasterxml.jackson.annotation.*;
6+
import com.fasterxml.jackson.core.Version;
47
import com.fasterxml.jackson.databind.*;
8+
import com.fasterxml.jackson.databind.deser.SettableBeanProperty;
9+
import com.fasterxml.jackson.databind.deser.ValueInstantiator;
10+
import com.fasterxml.jackson.databind.deser.ValueInstantiators;
511
import com.fasterxml.jackson.databind.deser.impl.PropertyValueBuffer;
612
import com.fasterxml.jackson.databind.deser.std.StdValueInstantiator;
713
import com.fasterxml.jackson.databind.module.SimpleModule;
@@ -262,6 +268,112 @@ public void setupModule(SetupContext context)
262268
}
263269
}
264270

271+
static class ClassWith32Props {
272+
@JsonCreator
273+
public ClassWith32Props(@JsonProperty("p1") String p1,
274+
@JsonProperty("p2") String p2,
275+
@JsonProperty("p3") String p3, @JsonProperty("p4") String p4,
276+
@JsonProperty("p5") String p5, @JsonProperty("p6") String p6,
277+
@JsonProperty("p7") String p7, @JsonProperty("p8") String p8,
278+
@JsonProperty("p9") String p9, @JsonProperty("p10") String p10,
279+
@JsonProperty("p11") String p11, @JsonProperty("p12") String p12,
280+
@JsonProperty("p13") String p13, @JsonProperty("p14") String p14,
281+
@JsonProperty("p15") String p15, @JsonProperty("p16") String p16,
282+
@JsonProperty("p17") String p17, @JsonProperty("p18") String p18,
283+
@JsonProperty("p19") String p19, @JsonProperty("p20") String p20,
284+
@JsonProperty("p21") String p21, @JsonProperty("p22") String p22,
285+
@JsonProperty("p23") String p23, @JsonProperty("p24") String p24,
286+
@JsonProperty("p25") String p25, @JsonProperty("p26") String p26,
287+
@JsonProperty("p27") String p27, @JsonProperty("p28") String p28,
288+
@JsonProperty("p29") String p29, @JsonProperty("p30") String p30,
289+
@JsonProperty("p31") String p31, @JsonProperty("p32") String p32) {
290+
this.p1 = p1;
291+
this.p2 = p2;
292+
this.p3 = p3;
293+
this.p4 = p4;
294+
this.p5 = p5;
295+
this.p6 = p6;
296+
this.p7 = p7;
297+
this.p8 = p8;
298+
this.p9 = p9;
299+
this.p10 = p10;
300+
this.p11 = p11;
301+
this.p12 = p12;
302+
this.p13 = p13;
303+
this.p14 = p14;
304+
this.p15 = p15;
305+
this.p16 = p16;
306+
this.p17 = p17;
307+
this.p18 = p18;
308+
this.p19 = p19;
309+
this.p20 = p20;
310+
this.p21 = p21;
311+
this.p22 = p22;
312+
this.p23 = p23;
313+
this.p24 = p24;
314+
this.p25 = p25;
315+
this.p26 = p26;
316+
this.p27 = p27;
317+
this.p28 = p28;
318+
this.p29 = p29;
319+
this.p30 = p30;
320+
this.p31 = p31;
321+
this.p32 = p32;
322+
}
323+
324+
public final String p1, p2, p3, p4;
325+
public final String p5, p6, p7, p8;
326+
public final String p9, p10, p11, p12;
327+
public final String p13, p14, p15, p16;
328+
public final String p17, p18, p19, p20;
329+
public final String p21, p22, p23, p24;
330+
public final String p25, p26, p27, p28;
331+
public final String p29, p30, p31, p32;
332+
}
333+
334+
static class VerifyingValueInstantiator extends StdValueInstantiator {
335+
protected VerifyingValueInstantiator(StdValueInstantiator src) {
336+
super(src);
337+
}
338+
339+
@Override
340+
public Object createFromObjectWith(DeserializationContext ctxt, SettableBeanProperty[] props, PropertyValueBuffer buffer) throws IOException {
341+
for (SettableBeanProperty prop : props) {
342+
assertTrue("prop " + prop.getName() + " was expected to have buffer.hasParameter(prop) be true but was false", buffer.hasParameter(prop));
343+
}
344+
return super.createFromObjectWith(ctxt, props, buffer);
345+
}
346+
}
347+
348+
// [databind#1432]
349+
350+
public static class ClassWith32Module extends SimpleModule {
351+
public ClassWith32Module() {
352+
super("test", Version.unknownVersion());
353+
}
354+
355+
@Override
356+
public void setupModule(SetupContext context) {
357+
context.addValueInstantiators(new ValueInstantiators.Base() {
358+
@Override
359+
public ValueInstantiator findValueInstantiator(DeserializationConfig config,
360+
BeanDescription beanDesc, ValueInstantiator defaultInstantiator) {
361+
if (beanDesc.getBeanClass() == ClassWith32Props.class) {
362+
return new VerifyingValueInstantiator((StdValueInstantiator)
363+
defaultInstantiator);
364+
}
365+
return defaultInstantiator;
366+
}
367+
});
368+
}
369+
}
370+
371+
/*
372+
/**********************************************************
373+
/* Test methods
374+
/**********************************************************
375+
*/
376+
265377
// When all values are in the source, no defaults should be used.
266378
public void testAllPresent() throws Exception
267379
{
@@ -415,4 +527,29 @@ public void testMoreThan32CreatorParams() throws Exception
415527
assertEquals(BigBucket.DEFAULT_S, big.s15);
416528
assertEquals(BigBucket.DEFAULT_S, big.s16);
417529
}
530+
531+
// [databind#1432]
532+
public void testClassWith32CreatorParams() throws Exception
533+
{
534+
StringBuilder sb = new StringBuilder()
535+
.append("{\n");
536+
for (int i = 1; i <= 32; ++i) {
537+
sb.append("\"p").append(i).append("\" : \"NotNull")
538+
.append(i).append("\"");
539+
if (i < 32) {
540+
sb.append(",\n");
541+
}
542+
}
543+
sb.append("\n}\n");
544+
String json = sb.toString();
545+
ObjectMapper mapper = new ObjectMapper()
546+
.registerModule(new ClassWith32Module());
547+
ClassWith32Props result = mapper.readValue(json, ClassWith32Props.class);
548+
// let's assume couple of first, last ones suffice
549+
assertEquals("NotNull1", result.p1);
550+
assertEquals("NotNull2", result.p2);
551+
assertEquals("NotNull31", result.p31);
552+
assertEquals("NotNull32", result.p32);
553+
}
418554
}
555+

src/test/java/com/fasterxml/jackson/databind/seq/SequenceWriterTest.java

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
package com.fasterxml.jackson.databind.seq;
22

33
import java.io.StringWriter;
4-
import java.util.Arrays;
5-
import java.util.Collection;
6-
import java.util.Collections;
4+
import java.util.*;
75

86
import com.fasterxml.jackson.annotation.JsonTypeInfo;
97
import com.fasterxml.jackson.annotation.JsonTypeName;
@@ -44,7 +42,7 @@ static class ImplB extends PolyBase {
4442

4543
public ImplB(int v) { b = v; }
4644
}
47-
45+
4846
/*
4947
/**********************************************************
5048
/* Test methods, simple writes

0 commit comments

Comments
 (0)