Skip to content

Commit 63afa52

Browse files
committed
Fix #1501
1 parent d3874eb commit 63afa52

File tree

4 files changed

+47
-0
lines changed

4 files changed

+47
-0
lines changed

release-notes/CREDITS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,3 +488,7 @@ Josh Caplan (jecaplan@github)
488488

489489
Frédéric Camblor (fcamblor@github)
490490
* Reported #1451: Type parameter not passed by `ObjectWriter` if serializer pre-fetch disabled
491+
492+
Kevin Hogeland (khogeland@github)
493+
* Reported #1501: `ArrayIndexOutOfBoundsException` on non-static inner class constructor
494+
(2.7.9)

release-notes/VERSION

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ Project: jackson-databind
2020
(reported by Dmitry S)
2121
#1476: Wrong constructor picked up when deserializing object
2222
(reported by laurentgo@github)
23+
#1501: `ArrayIndexOutOfBoundsException` on non-static inner class constructor
24+
(reported by Kevin H)
2325
#1506: Missing `KeyDeserializer` for `CharSequence`
2426

2527
2.7.8 (26-Sep-2016)

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,15 @@ public InnerClassProperty withName(PropertyName newName) {
8383
public InnerClassProperty withValueDeserializer(JsonDeserializer<?> deser) {
8484
return new InnerClassProperty(this, deser);
8585
}
86+
87+
@Override
88+
public void assignIndex(int index) { _delegate.assignIndex(index); }
89+
90+
@Override
91+
public int getPropertyIndex() { return _delegate.getPropertyIndex(); }
92+
93+
@Override
94+
public int getCreatorIndex() { return _delegate.getCreatorIndex(); }
8695

8796
// // // BeanProperty impl
8897

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package com.fasterxml.jackson.databind.creators;
2+
3+
import com.fasterxml.jackson.annotation.JsonCreator;
4+
import com.fasterxml.jackson.annotation.JsonProperty;
5+
import com.fasterxml.jackson.databind.*;
6+
7+
// for [databind#1501]
8+
public class InnerClassCreatorTest extends BaseMapTest
9+
{
10+
static class Something {
11+
public InnerSomething a;
12+
13+
// important: must name the parameter (param names module, or explicit)
14+
@JsonCreator
15+
public Something(@JsonProperty("a") InnerSomething a) { this.a = a; }
16+
17+
public Something() { a = new InnerSomething(); }
18+
19+
class InnerSomething {
20+
@JsonCreator
21+
public InnerSomething() { }
22+
}
23+
}
24+
25+
public void testIssue1501() throws Exception
26+
{
27+
ObjectMapper mapper = new ObjectMapper();
28+
mapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
29+
String ser = mapper.writeValueAsString(new Something());
30+
mapper.readValue(ser, Something.class);
31+
}
32+
}

0 commit comments

Comments
 (0)