Skip to content

Commit

Permalink
8261290: Improve error message for NumberFormatException on null input
Browse files Browse the repository at this point in the history
Reviewed-by: attila, alanb
  • Loading branch information
jddarcy committed Feb 21, 2021
1 parent 18188c2 commit 564011c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/java.base/share/classes/java/lang/Integer.java
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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();
Expand Down
6 changes: 3 additions & 3 deletions src/java.base/share/classes/java/lang/Long.java
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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();
Expand Down

1 comment on commit 564011c

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.