NumberTypeConverterSupport fails with some unusual Locales
-----------------------------------------------------------
Key: STS-757
URL: http://www.stripesframework.org/jira/browse/STS-757
Project: Stripes
Issue Type: Bug
Components: Validation
Affects Versions: Release 1.5.3
Reporter: Michael Krkoska
Priority: Minor
NumberTypeConverterSupport.setLocale(Locale) includes this code:
if (locale.getCountry() != null && !"".equals(locale.getCountry()))
this.currencySymbol =
Currency.getInstance(locale).getSymbol(locale);
Unfortunately for Locales where there is no Currency for the Locale's country,
this fails:
java.lang.IllegalArgumentException
at java.util.Currency.getInstance(Currency.java:260)
Obviously a way to prevent this, is not to use such Locales. But let's see what
java.text.DecimalFormatSymbols does in its initialize(Locale):
if (!"".equals(locale.getCountry())) {
try {
currency = Currency.getInstance(locale);
} catch (IllegalArgumentException e) {
// use default values below for compatibility
}
}
I propose to patch NumberTypeConverterSupport to fix this behaviour.
Instead of
if (locale.getCountry() != null && !"".equals(locale.getCountry()))
this.currencySymbol =
Currency.getInstance(locale).getSymbol(locale);
else
this.currencySymbol = "$";
I'd like
this.currencySymbol = "$";
if (locale.getCountry() != null && !"".equals(locale.getCountry())){
try {
this.currencySymbol =
Currency.getInstance(locale).getSymbol(locale);
} catch (IllegalArgumentException e) {
// use dollar as default value
}
}
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://www.stripesframework.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
Stripes-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-development