Skip to content

Commit 866e338

Browse files
committed
Merge branch '2.20' into 2.x
2 parents 52c2f49 + 01acbc1 commit 866e338

File tree

3 files changed

+25
-19
lines changed

3 files changed

+25
-19
lines changed

release-notes/VERSION-2.x

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ Project: jackson-databind
1212
#5293: Fix minor typo in `PropertyBindingException.getMessageSuffix()`
1313
(reported by Johny L)
1414

15+
2.20.1 (not yet released)
16+
17+
#5292: `MapperFeature.FIX_FIELD_NAME_UPPER_CASE_PREFIX` does not work with
18+
Constructor parameters
19+
(reported by @bananayong)
20+
1521
2.20.0 (28-Aug-2025)
1622

1723
#2678: `@JacksonInject` added to property overrides value from the JSON

src/main/java/com/fasterxml/jackson/databind/introspect/POJOPropertiesCollector.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1373,20 +1373,22 @@ protected void _fixLeadingFieldNameCase(Map<String, POJOPropertyBuilder> props)
13731373

13741374
// First: find possible candidates where:
13751375
//
1376-
// 1. Property only has Field
1377-
// 2. Field does NOT have explicit name (renaming)
1378-
// 3. Implicit name has upper-case for first and/or second character
1376+
// 1. Property has Field and/or Constructor Parameter
1377+
// 2. Property has no other accessors (no getters/setters)
1378+
// 3. Field/Constructor param does NOT have explicit name (renaming)
1379+
// 4. Implicit name has upper-case for first and/or second character
13791380

13801381
Map<String, POJOPropertyBuilder> fieldsToCheck = null;
13811382
for (Map.Entry<String, POJOPropertyBuilder> entry : props.entrySet()) {
13821383
POJOPropertyBuilder prop = entry.getValue();
13831384

1384-
// First: (1) and (2)
1385-
if (!prop.hasFieldAndNothingElse()
1386-
|| prop.isExplicitlyNamed()) {
1385+
// First: (1), (2) and 3
1386+
if (prop.isExplicitlyNamed() // (3)
1387+
|| !(prop.hasField() || prop.hasConstructorParameter()) // (1)
1388+
|| (prop.hasGetter() || prop.hasSetter())) { // 2
13871389
continue;
13881390
}
1389-
// Second: (3)
1391+
// Second: (4)
13901392
if (!_firstOrSecondCharUpperCase(entry.getKey())) {
13911393
continue;
13921394
}

src/test/java/com/fasterxml/jackson/databind/tofix/FixFieldNameUpperCasePrefix5292Test.java renamed to src/test/java/com/fasterxml/jackson/databind/misc/IPhoneStyleProperty5292Test.java

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.fasterxml.jackson.databind.tofix;
1+
package com.fasterxml.jackson.databind.misc;
22

33
import org.junit.jupiter.api.Test;
44

@@ -9,13 +9,12 @@
99
import com.fasterxml.jackson.databind.ObjectMapper;
1010
import com.fasterxml.jackson.databind.json.JsonMapper;
1111
import com.fasterxml.jackson.databind.testutil.DatabindTestUtil;
12-
import com.fasterxml.jackson.databind.testutil.failure.JacksonTestFailureExpected;
1312

1413
import static org.junit.jupiter.api.Assertions.assertEquals;
1514

1615
// [databind#5292] Need support for creators `MapperFeature.FIX_FIELD_NAME_UPPER_CASE_PREFIX`
17-
public class FixFieldNameUpperCasePrefix5292Test
18-
extends DatabindTestUtil
16+
public class IPhoneStyleProperty5292Test
17+
extends DatabindTestUtil
1918
{
2019
static class AppleSingleNonTarget {
2120
private final String name;
@@ -45,17 +44,17 @@ public String getIPhone() {
4544
// Creator order should be used but just in case, define explicit order
4645
@JsonPropertyOrder({ "iPhone", "name" })
4746
static class AppleDouble {
48-
private final String iPhone;
47+
private final String _iphone;
4948
private final String name;
5049

5150
public AppleDouble(@ImplicitName("iPhone") String iPhone,
5251
@ImplicitName("name") String name) {
53-
this.iPhone = iPhone;
52+
this._iphone = iPhone;
5453
this.name = name;
5554
}
5655

5756
public String getIPhone() {
58-
return iPhone;
57+
return _iphone;
5958
}
6059

6160
public String getName() {
@@ -68,7 +67,6 @@ public String getName() {
6867
.enable(MapperFeature.FIX_FIELD_NAME_UPPER_CASE_PREFIX)
6968
.build();
7069

71-
@JacksonTestFailureExpected
7270
@Test
7371
public void testDeserDouble() throws Exception
7472
{
@@ -79,18 +77,18 @@ public void testDeserDouble() throws Exception
7977
AppleDouble result = MAPPER.readValue(json, AppleDouble.class); // Error thrown
8078

8179
assertEquals("Jay", result.getName());
82-
assertEquals("iPhone 15", result.getName());
80+
assertEquals("iPhone 15", result.getIPhone());
8381
}
8482

85-
@JacksonTestFailureExpected
83+
8684
@Test
8785
public void testSingleArgCase() throws Exception
8886
{
8987
AppleSingleIsTarget apple = new AppleSingleIsTarget("iPhone 15");
9088
String json = MAPPER.writeValueAsString(apple);
9189
assertEquals("{\"iPhone\":\"iPhone 15\"}", json);
9290

93-
AppleSingleIsTarget result = MAPPER.readValue(json, AppleSingleIsTarget.class); // Error thrown
91+
AppleSingleIsTarget result = MAPPER.readValue(json, AppleSingleIsTarget.class);
9492
assertEquals("iPhone 15", result.getIPhone());
9593
}
9694

@@ -102,7 +100,7 @@ public void testHappyCaseSingleArgString() throws Exception
102100
String json = MAPPER.writeValueAsString(apple);
103101
assertEquals("{\"name\":\"Jay\"}", json);
104102

105-
AppleSingleNonTarget result = MAPPER.readValue(json, AppleSingleNonTarget.class); // Error thrown
103+
AppleSingleNonTarget result = MAPPER.readValue(json, AppleSingleNonTarget.class);
106104
assertEquals("Jay", result.getName());
107105
}
108106
}

0 commit comments

Comments
 (0)