Skip to content

Commit

Permalink
Merge branch '2.17' into 2.18
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Apr 6, 2024
2 parents a29f346 + 7c9e7c1 commit e6145c3
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
2 changes: 2 additions & 0 deletions release-notes/VERSION-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ Project: jackson-databind
String ".05": not a valid representation
(reported by @EAlf91)
(fix by @pjfanning)
#4450: Empty QName deserialized as `null`
(reported by @winfriedgerlach)

2.17.0 (12-Mar-2024)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ protected Object _deserializeFromEmptyString(DeserializationContext ctxt) throws
if (act == CoercionAction.AsEmpty) {
return getEmptyValue(ctxt);
}
// 09-Jun-2020, tatu: semantics for `TryConvert` are bit interesting due to
// 09-Jun-2020, tatu: semantics for `TryConvert` are a bit interesting due to
// historical reasons
return _deserializeFromEmptyStringDefault(ctxt);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@
*/
public class CoreXMLDeserializers extends Deserializers.Base
{
protected final static QName EMPTY_QNAME = QName.valueOf("");

/**
* Data type factories are thread-safe after instantiation (and
* configuration, if any); and since instantion (esp. implementation
* configuration, if any); and since instantiation (esp. implementation
* introspection) can be expensive we better reuse the instance.
*/
final static DatatypeFactory _dataTypeFactory;
Expand Down Expand Up @@ -125,6 +127,14 @@ protected Object _deserialize(String value, DeserializationContext ctxt)
throw new IllegalStateException();
}

@Override
protected Object _deserializeFromEmptyString(DeserializationContext ctxt) throws IOException {
if (_kind == TYPE_QNAME) {
return EMPTY_QNAME;
}
return super._deserializeFromEmptyString(ctxt);
}

protected XMLGregorianCalendar _gregorianFromDate(DeserializationContext ctxt,
Date d)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ public void testQNameDeser() throws Exception
String qstr = qn.toString();
assertEquals(qn, MAPPER.readValue(q(qstr), QName.class),
"Should deserialize to equal QName (exp serialization: '"+qstr+"')");

// [databind#4450]
qn = MAPPER.readValue(q(""), QName.class);
assertNotNull(qn);
assertEquals("", qn.getLocalPart());
}

@Test
Expand Down

0 comments on commit e6145c3

Please sign in to comment.