JDK-7133642 : Double.parseDouble(null) throws NullPointerExeption, not NumberFormatExcep
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang
  • Affected Version: 6u29
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_7
  • CPU: x86
  • Submitted: 2012-01-26
  • Updated: 2012-03-30
  • Resolved: 2012-03-20
Related Reports
Duplicate :  
Description
FULL PRODUCT VERSION :
Version 1.6.0_30 and 1.6.0_29

C:\>\Java\jdk1.6.0_30\bin\java.exe -version
java version "1.6.0_30"
Java(TM) SE Runtime Environment (build 1.6.0_30-b12)
Java HotSpot(TM) 64-Bit Server VM (build 20.5-b03, mixed mode)

C:\>\Java\jdk1.6.0_29\bin\java.exe -version
java version "1.6.0_29"
Java(TM) SE Runtime Environment (build 1.6.0_29-b11)
Java HotSpot(TM) 64-Bit Server VM (build 20.4-b02, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
6.1.7600

A DESCRIPTION OF THE PROBLEM :
Double.parseDouble(null) throws NullPointerException instead of NumberFormatException.

This is inconsistent with the Javadoc and the behavior of Long.parseLong().

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Call Double.parseDouble() with null param.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
throws NumberFormatException
ACTUAL -
throw NullPointerException

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
	public static void main(String[] args) {
		
		System.out.println(System.getProperties().toString());

		System.out.println("Running Long.parseLong(null)");
		
		try {
			Long.parseLong(null);
		} catch (NumberFormatException nfe){
			System.out.println("Caught NumberFormatException");
		} catch (NullPointerException npe){
			System.out.println("Caught NullPointerException");
		}
		
		System.out.println("Running Double.parseDouble(null)");
		
		try {
			Double.parseDouble(null);
		} catch (NumberFormatException nfe){
			System.out.println("Caught NumberFormatException");
		} catch (NullPointerException npe){
			System.out.println("Caught NullPointerException");
		}
	}
---------- END SOURCE ----------

Comments
EVALUATION Closing as a duplicate of 6463998.
20-03-2012