Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -719,8 +719,9 @@ protected void _addCreators(Map<String, POJOPropertyBuilder> props)
&& !ctorDetector.requireCtorAnnotation()) {
// But only if no Default (0-params) constructor available OR if we are configured
// to prefer properties-based Creators
if ((_classDef.getDefaultConstructor() == null)
|| ctorDetector.singleArgCreatorDefaultsToProperties()) {
// 09-Sep-2025, tatu: [databind#5045] Actually let's allow implicit even in
// case of also having 0-param constructor (un-annotated at this point)
if ((zeroParamsConstructor == null) || !zeroParamsConstructor.isAnnotated()) {
_addImplicitConstructor(creators, constructors, props);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package tools.jackson.databind.deser.creators;

import tools.jackson.databind.*;
import tools.jackson.databind.testutil.DatabindTestUtil;

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

import org.junit.jupiter.api.Test;

public class NoParamsCreator5246Test extends DatabindTestUtil
{
static class Pojo5246 {
final int productId;
final String name;

public Pojo5246() {
this(0, null);
}

public Pojo5246(int productId, String name) {
this.productId = productId;
this.name = name;
}
}

// For [databind#5246]
@Test
void testNoParamsCreator() throws Exception {
ObjectMapper mapper = jsonMapperBuilder()
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, true)
.build();
Pojo5246 pojo = mapper.readValue("{\"productId\":1,\"name\":\"foo\"}", Pojo5246.class);
assertEquals(1, pojo.productId);
assertEquals("foo", pojo.name);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ static FactoryFromPoint createIt(Point p)
// Also: let's test BigDecimal-from-JSON-String factory
static class FactoryFromDecimalString
{
int _value;
int _value;

private FactoryFromDecimalString(BigDecimal d) {
_value = d.intValue();
Expand Down
Loading