konradk

TypeError enum Type methods should not use default user locales

Discussion created by konradk on Apr 11, 2016
Latest reply on Apr 13, 2016 by konradk

The methods toString and fromString in enum Type in class XMPPError do not handle well some of the locales like Turkish.

There are some comments in the source code saying the Locale.US is not needed but that is not true.

// Locale.US not required, since Type consists only of ASCII chars

 

For example, if user is using Turkish language in the system and if Smack receives some error IQ with type "wait", the method fromString will convert it to "WAİT" which will result in IllegalArgumentException as there is no enum with Type.WAİT

 

Just to confirm my words: https://ideone.com/4cXJTs

 

In my opinion both methods should use Locale.US as in the rest places of the Smack's code.

Outcomes