Details
-
Type: Bug
-
Status: Closed
-
Priority: Major
-
Resolution: Not A Bug
-
Affects Version/s: 1.3
-
Fix Version/s: 1.x Maintenance
-
Component/s: Converters
-
Labels:None
Description
Hi,
I've got a exception when XStream try to convert a empty element mapped with a Date.
I use the ISO8601DateConverter.
<product> <productId>10454</productId> <title>Playlist 1</title> <type>playlist</type> <summary/> <restrictedAccess>0</restrictedAccess> <media> <cover>XXXX</cover> </media> <artistList> <artists></artists> <offset>0</offset> <count>1</count> <total>1</total> </artistList> <label/> <releaseDate/> <flag> <topvente>99</topvente> <selection>99</selection> <new>99</new> </flag> </product>
I've resolved this by overiding the fromString method
@Override public Object fromString(String str) { if (StringUtils.isNotBlank(str)) return ((Calendar)super.fromString(str)).getTime(); return null; }
Damien
Each converter expects string values that are valid for its format. If the original value was null, the element is not even part of the XML. Therefore an empty String will raise an exception.