OpenJDK / jdk / hs
changeset 46893:4c5a4cd5b092
6609718: [Fmt-Ch] uninformative exception in ChoiceFormat.applyPattern(String)
Reviewed-by: naoto
Contributed-by: nishit.jain@oracle.com
author | nishjain |
---|---|
date | Tue, 22 Aug 2017 12:04:53 +0530 |
parents | fd5023dd3c85 |
children | 8e950730d2c8 5ae11f15e343 |
files | jdk/src/java.base/share/classes/java/text/ChoiceFormat.java |
diffstat | 1 files changed, 13 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/jdk/src/java.base/share/classes/java/text/ChoiceFormat.java Tue Aug 22 07:52:40 2017 +0200 +++ b/jdk/src/java.base/share/classes/java/text/ChoiceFormat.java Tue Aug 22 12:04:53 2017 +0530 @@ -202,26 +202,26 @@ segments[part].append(ch); } else if (ch == '<' || ch == '#' || ch == '\u2264') { if (segments[0].length() == 0) { - throw new IllegalArgumentException(); + throw new IllegalArgumentException("Each interval must" + + " contain a number before a format"); } - try { - String tempBuffer = segments[0].toString(); - if (tempBuffer.equals("\u221E")) { - startValue = Double.POSITIVE_INFINITY; - } else if (tempBuffer.equals("-\u221E")) { - startValue = Double.NEGATIVE_INFINITY; - } else { - startValue = Double.valueOf(segments[0].toString()).doubleValue(); - } - } catch (Exception e) { - throw new IllegalArgumentException(); + + String tempBuffer = segments[0].toString(); + if (tempBuffer.equals("\u221E")) { + startValue = Double.POSITIVE_INFINITY; + } else if (tempBuffer.equals("-\u221E")) { + startValue = Double.NEGATIVE_INFINITY; + } else { + startValue = Double.valueOf(tempBuffer); } + if (ch == '<' && startValue != Double.POSITIVE_INFINITY && startValue != Double.NEGATIVE_INFINITY) { startValue = nextDouble(startValue); } if (startValue <= oldStartValue) { - throw new IllegalArgumentException(); + throw new IllegalArgumentException("Incorrect order of" + + " intervals, must be in ascending order"); } segments[0].setLength(0); part = 1;