Summary
Enforce NPE on all java.text.DecimalFormatSymbols setter methods where applicable.
Problem
There is inconsistency with NPE in regards to the setter methods of DecimalFormatSymbols. Currently, invoking equals can lead to an NPE as some instance variables are nullable. It was an oversight for the methods in question to not enforce NPE as well.
Solution
Enforce NPE on the following 4 setter methods: setInfinity(String)
, setNaN(String)
, setCurrencySymbol(String)
, and setInternationalCurrencySymbol(String)
. Additionally, update the logic in setInternationalCurrencySymbol(String)
such that if the passed currency code is not valid, instead of nulling the currency field, the currency field is simply not updated. Please see the Compatibility Risk Description for further information.
Minor spec updates included as well.
Specification
Add throws tag in setInfinity(String infinity),
* @param infinity the string representing infinity
+ * @throws NullPointerException if {@code infinity} is {@code null}
*/
public void setInfinity(String infinity) {
Add throws tag in setNaN(String NaN),
* @param NaN the string representing "not a number"
+ * @throws NullPointerException if {@code NaN} is {@code null}
*/
public void setNaN(String NaN) {
Add throws tag and minor spec update in setCurrencySymbol(String currency),
- * Sets the currency symbol for the currency of these
- * DecimalFormatSymbols in their locale.
+ * Sets the currency symbol for the currency of this
+ * {@code DecimalFormatSymbols} in their locale. Unlike {@link
+ * #setInternationalCurrencySymbol(String)}, this method does not update
+ * the currency attribute nor the international currency symbol attribute.
*
* @param currency the currency symbol
+ * @throws NullPointerException if {@code currency} is {@code null}
* @since 1.2
*/
public void setCurrencySymbol(String currency)
Add throws tag and minor spec update in setInternationalCurrencySymbol(String currencyCode),
* in the DecimalFormatSymbols' locale. If the currency code is not valid,
- * then the currency attribute is set to null and the currency symbol
- * attribute is not modified.
+ * then the currency attribute and the currency symbol attribute are not modified.
*
* @param currencyCode the currency code
+ * @throws NullPointerException if {@code currencyCode} is {@code null}
* @see #setCurrency
* @see #setCurrencySymbol
* @since 1.2
*/
public void setInternationalCurrencySymbol(String currencyCode)
A minor wording update to setCurrency(Currency currency),
/**
- * Sets the currency of these DecimalFormatSymbols.
+ * Sets the currency of this {@code DecimalFormatSymbols}.
* This also sets the currency symbol attribute to the currency's symbol
A minor wording update to getCurrency(),
/**
- * Gets the currency of these DecimalFormatSymbols. May be null if the
- * currency symbol attribute was previously set to a value that's not
- * a valid ISO 4217 currency code.
- *
- * @return the currency used, or null
+ * {@return the {@code Currency} of this {@code DecimalFormatSymbols}}
* @since 1.4
*/
public Currency getCurrency() {
- csr of
-
JDK-8341445 DecimalFormatSymbols setters should throw NPE
- Resolved