Patch: Improve Delay Information Parser

Hi,

here is a patch that fixes the long outstanding ticket SMACK-243. If the parser for delayed delivery nodes (XEP-0203) encounters a date format it cannot parse a ParseException was thrown which led to a disconnect to the XMPP server.

The old implementation had another bug caused by simply trying out different date format parsers. If multiple parsers could be applied to a date string only the first one is used although another one might be more specific for that date string. This could result in totally wrong parsed dates that may even lie in the future.

The patched implementation tries to choose the correct date parser by analyzing the date string with a regular expression first. It can also handle ambiguous dates where the leading zeros of the month or day are missing.
If all efforts fail and the date could not be parsed the current date is set as timestamp.
The parser will still crash on invalid XML though.

The patch comes with some unit tests that require the library java-xmlbuilder.
The java-xmlbuilder is a small and powerful library to easily and clearly create XML documents (compared to the ugliness of creating XML by concatenating strings and variables).
Download the library here and put the jar file in the build/build/ folder (next to the xmlunit library).

Best regards,
Henning
improve_delay_information_parser.patch.zip (6200 Bytes)