GeoLocationProvider bug (error field)

The GeoLocationProvider expects an error field tries to parse the value as a Double.

https://github.com/igniterealtime/Smack/blob/master/smack-extensions/src/main/ja va/org/jivesoftware/smackx/geoloc/provider/GeoLocationProvider.java#L71

The GeoLocation constructor sets this to null incase the accuracy field is set

Smack/GeoLocation.java at master · igniterealtime/Smack · GitHub

Issues

  1. The parser throws an exception when parsing a geolocation message due to the error field being null

  2. Why does the parser need all the fields to be defined. There are so many fields of type double and all need to be defined. The GeoLocation builder doesn’t mandate all the fields, but the parser does. Ideally parser should parse a GeoLocation message with any of the fields set, and should be tolerant of missing fields

I don’t see that those fields have to be defined. Care to elaborate?

From what I observe, with this

GeoLocation.builder().setLat(34.0219).setLon(118.4814).build();

A message like this is formed and send to server

nullnullnullWGS84</d atum>null34.0219118.4814null

These nulls are being parsed as double by parser and there is a parse failure when received. Maybe the parser can ignore these invalid fields and proceed parsing further

Even when the accuracy, alt, bearing, error, lat, lon, speed are all set, the error field is being set to null (if accuracy exists) in the GeoLocation constructor. So the xml message will have null for error field. And parsing fails.

Let me know if it is still unclear

Ahh right, that’s a bug. I’ll ask ishan to fix it.

I believe this was already fixed with https://github.com/igniterealtime/Smack/commit/cf2027fce7828edce0aa59b46ce3df7d1 7eca793

I believe the parser too should be modified to ignore fields which are not parseable. Just my thoughts.

Or you could fix the entity generating the invalid geoloc extension.

One may not always have control over it. Especially with xmpp, where multiple libraries/clients may generate the messages.

If an unparseable geoloc message is in the system, the parser will keep crashing everytime.