8068278: ArrayIndexOutOfBoundsException instead of DateTimeException in j.t.chrono.JapaneseChronology.eraOf()

Corrected era range check

Reviewed-by: mchung, lancea
This commit is contained in:
Roger Riggs 2015-02-03 14:39:57 -05:00
parent bb5e8afcf2
commit ddb472a4dc
2 changed files with 27 additions and 3 deletions

View file

@ -195,10 +195,11 @@ public final class JapaneseEra
* @throws DateTimeException if the value is invalid
*/
public static JapaneseEra of(int japaneseEra) {
if (japaneseEra < MEIJI.eraValue || japaneseEra + ERA_OFFSET > KNOWN_ERAS.length) {
int i = ordinal(japaneseEra);
if (i < 0 || i >= KNOWN_ERAS.length) {
throw new DateTimeException("Invalid era: " + japaneseEra);
}
return KNOWN_ERAS[ordinal(japaneseEra)];
return KNOWN_ERAS[i];
}
/**