Skip to content

add extra number test #717

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 9, 2025
Merged
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 @@ -74,6 +74,24 @@ static class NestedFloatHolder2784 {
public FloatHolder2784 holder;
}

static class DeserializationIssue4917 {
public DecimalHolder4917 decimalHolder;
public double number;
}

static class DecimalHolder4917 {
public BigDecimal value;

private DecimalHolder4917(BigDecimal value) {
this.value = value;
}

@JsonCreator(mode = JsonCreator.Mode.DELEGATING)
static DecimalHolder4917 of(BigDecimal value) {
return new DecimalHolder4917(value);
}
}

/*
/**********************************************************************
/* Test methods
Expand Down Expand Up @@ -160,4 +178,15 @@ public void testVeryBigDecimalUnwrappedWithUnlimitedNumLength() throws Exception
NestedBigDecimalHolder2784 result = new XmlMapper(f).readValue(DOC, NestedBigDecimalHolder2784.class);
assertEquals(new BigDecimal(value), result.holder.value);
}

// [databind#4917]
@Test
public void bigDecimal4917() throws Exception
{
DeserializationIssue4917 issue = MAPPER.readValue(
"<root><decimalHolder>100.00</decimalHolder><number>50</number></root>",
DeserializationIssue4917.class);
assertEquals(new BigDecimal("100.00"), issue.decimalHolder.value);
assertEquals(50.0, issue.number);
}
}