Skip to content
Permalink
Browse files
8261290: Improve error message for NumberFormatException on null input
Reviewed-by: attila, alanb
  • Loading branch information
jddarcy committed Feb 21, 2021
1 parent 18188c2 commit 564011cff0667c6d34cf6aa46eedd11f2e01862b
Showing with 6 additions and 6 deletions.
  1. +3 −3 src/java.base/share/classes/java/lang/Integer.java
  2. +3 −3 src/java.base/share/classes/java/lang/Long.java
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1994, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1994, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -627,7 +627,7 @@ public static int parseInt(String s, int radix)
*/

if (s == null) {
throw new NumberFormatException("null");
throw new NumberFormatException("Cannot parse null string");
}

if (radix < Character.MIN_RADIX) {
@@ -832,7 +832,7 @@ public static int parseInt(String s) throws NumberFormatException {
public static int parseUnsignedInt(String s, int radix)
throws NumberFormatException {
if (s == null) {
throw new NumberFormatException("null");
throw new NumberFormatException("Cannot parse null string");
}

int len = s.length();
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1994, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1994, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -682,7 +682,7 @@ public static long parseLong(String s, int radix)
throws NumberFormatException
{
if (s == null) {
throw new NumberFormatException("null");
throw new NumberFormatException("Cannot parse null string");
}

if (radix < Character.MIN_RADIX) {
@@ -893,7 +893,7 @@ public static long parseLong(String s) throws NumberFormatException {
public static long parseUnsignedLong(String s, int radix)
throws NumberFormatException {
if (s == null) {
throw new NumberFormatException("null");
throw new NumberFormatException("Cannot parse null string");
}

int len = s.length();

1 comment on commit 564011c

@openjdk-notifier

This comment has been minimized.

Copy link

@openjdk-notifier openjdk-notifier bot commented on 564011c Feb 21, 2021

Please sign in to comment.