Skip to content

Commit

Permalink
Fix #398 for 2.3.2 as well
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Feb 5, 2014
1 parent 75a9738 commit ce11121
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
2 changes: 2 additions & 0 deletions release-notes/VERSION
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Version: 2.3.2 (xx-xxx-2014)
#379: Fix a problem with (re)naming of Creator properties; needed to make
Paranamer module work with NamingStrategy.
(reported by Chris P, cpilsworth@github)
#398: Should deserialize empty (not null) URI from empty String
(reported by pgieser@github)
- Added `BeanSerializerBase._serializeObjectId()` needed by modules that
override standard BeanSerializer; specifically, XML module.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ protected FromStringDeserializer(Class<?> vc) {
/* Deserializer implementations
/**********************************************************
*/

@SuppressWarnings("unchecked")
@Override
public final T deserialize(JsonParser jp, DeserializationContext ctxt)
Expand All @@ -34,8 +34,7 @@ public final T deserialize(JsonParser jp, DeserializationContext ctxt)
String text = jp.getValueAsString();
if (text != null) { // has String representation
if (text.length() == 0 || (text = text.trim()).length() == 0) {
// 15-Oct-2010, tatu: Empty String usually means null, so
return null;
return _deserializeFromEmptyString();
}
try {
T result = _deserialize(text, ctxt);
Expand Down Expand Up @@ -72,4 +71,5 @@ protected T _deserializeEmbedded(Object ob, DeserializationContext ctxt)
+ob.getClass().getName()+" into "+_valueClass.getName());
}

protected T _deserializeFromEmptyString() { return null; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,12 @@ protected URI _deserialize(String value, DeserializationContext ctxt)
{
return URI.create(value);
}

@Override
protected URI _deserializeFromEmptyString() {
// [#398] Need to produce non-null URI from empty String
return URI.create("");
}
}

public static class CurrencyDeserializer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,11 @@ public void testURI() throws Exception
{
URI value = new URI("http://foo.com");
assertEquals(value, MAPPER.readValue("\""+value.toString()+"\"", URI.class));

// [#398]
value = MAPPER.readValue(quote(""), URI.class);
assertNotNull(value);
assertEquals(URI.create(""), value);
}

/*
Expand Down

0 comments on commit ce11121

Please sign in to comment.