We're updating the issue view to help you get more done. 

DecimalFormat accepts null pattern

Description

ICU 59 changed the behaviour of the DecimalFormat constructor and applyPattern to accept null (and treat it like the empty string).

Previously new DecimalFormat(null) and format.applyPattern(null) would throw NPEs, which seems more correct IMO.

These JUnit tests pass on ICU 58 and fail with 59:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 @Test(expected = NullPointerException.class) public void test_DecimalFormat_constructor_null() { new DecimalFormat(null); } @Test(expected = NullPointerException.class) public void test_DecimalFormat_constructor_null_dfs() { new DecimalFormat(null, new DecimalFormatSymbols()); } @Test public void test_DecimalFormat_applyPattern_null() { DecimalFormat format = (DecimalFormat) DecimalFormat.getInstance(); try { format.applyPattern(null); fail(); } catch (NullPointerException expected) { } }

Environment

Status

Assignee

Shane Carr

Reporter

TracBot

tracCc

jsauer

tracCreated

Jun 07, 2017, 4:21 PM

tracOwner

shane

tracProject

ICU4J

tracReporter

Joachim Sauer <jsauer@45913043a294ac57

tracResolution

fixed

tracReviewer

andy

tracStatus

closed

Components

Fix versions

Priority

major