JDK-8080644 : DateTimeFormatter throw a NullPointerException when parsing Zone id or name
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.time
  • Affected Version: 9
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: linux
  • CPU: x86_64
  • Submitted: 2015-05-16
  • Updated: 2015-10-08
  • Resolved: 2015-10-08
Related Reports
Duplicate :  
Description
FULL PRODUCT VERSION :
Picked up JAVA_TOOL_OPTIONS: -javaagent:/usr/share/java/jayatanaag.jar 
java version "1.9.0-ea"
Java(TM) SE Runtime Environment (build 1.9.0-ea-b63)
Java HotSpot(TM) 64-Bit Server VM (build 1.9.0-ea-b63, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Linux ananas 3.13.0-32-generic #57-Ubuntu SMP Tue Jul 15 03:51:08 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

A DESCRIPTION OF THE PROBLEM :
Parsing a date from a String with a pattern containing a zone id or zone pattern throw a DateTimeParseException with a NullPointerException as a root cause. 

REGRESSION.  Last worked in version 8u25

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
parse a date based on a format with a zone name or zone id.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Return a ZonedDateTime with the correct value.
ACTUAL -
Throw a DateTimeParseException exception.

ERROR MESSAGES/STACK TRACES THAT OCCUR :
java.time.format.DateTimeParseException: Text '20150128 12:03:56 PST' could not be parsed: null
	at java.time.format.DateTimeFormatter.createError(DateTimeFormatter.java:1920)
	at java.time.format.DateTimeFormatter.parse(DateTimeFormatter.java:1855)
	at java.time.ZonedDateTime.parse(ZonedDateTime.java:598)
	at org.sfm.csv.impl.CellValueReaderFactoryImplTest.testJavaZonedDateTime(CellValueReaderFactoryImplTest.java:120)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
	at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:78)
	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:212)
	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:68)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)
Caused by: java.lang.NullPointerException
	at java.time.format.DateTimeFormatterBuilder$PrefixTree.prefixLength(DateTimeFormatterBuilder.java:4137)
	at java.time.format.DateTimeFormatterBuilder$PrefixTree.add0(DateTimeFormatterBuilder.java:4006)
	at java.time.format.DateTimeFormatterBuilder$PrefixTree.add(DateTimeFormatterBuilder.java:4001)
	at java.time.format.DateTimeFormatterBuilder$ZoneTextPrinterParser.getTree(DateTimeFormatterBuilder.java:3752)
	at java.time.format.DateTimeFormatterBuilder$ZoneIdPrinterParser.parse(DateTimeFormatterBuilder.java:3859)
	at java.time.format.DateTimeFormatterBuilder$CompositePrinterParser.parse(DateTimeFormatterBuilder.java:2212)
	at java.time.format.DateTimeFormatter.parseUnresolved0(DateTimeFormatter.java:2010)
	at java.time.format.DateTimeFormatter.parseResolved0(DateTimeFormatter.java:1939)
	at java.time.format.DateTimeFormatter.parse(DateTimeFormatter.java:1851)
	... 28 more

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
   String date = "20150128 12:03:56 PST";
    final DateTimeFormatter yyyyMMdd = DateTimeFormatter.ofPattern("yyyyMMdd HH:mm:ss z");
    java.time.ZonedDateTime localTime = java.time.ZonedDateTime.parse(date, yyyyMMdd);
 
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
seemed to be working with a -08:30 instead of the zone name.


Comments
Still might be reproducible with -Djava.locale.providers=JRE,SPI,CLDR
08-10-2015

Closing this issue based upon submitter's response: --------------------------------------------------------------------------------------------------- On 7/15/2015 3:37 AM, ...... wrote: > Hi ...., > I just tried with b72 and it's working fine now. > You can close the ticket. > Thanks, ........ . -------------------------------------------------------------------------------------------------------
15-07-2015

Sent an email to the submitter requesting confirmation. ------------------------------------------------------------------------------------------- Hi ............, The issue reported by you is not reproducible with JDK 9 ea b63 and 8u60 ea b14. Can you please recheck with the latest builds and inform us back if you are still able to reproduce this issue? Thank You, ........... -------------------------------------------------------------------------------------------
03-06-2015

The problem could not be reproduced with the version of jdk from the report: ~/java9/jdk/bin/java -showversion A java version "1.9.0-ea" Java(TM) SE Runtime Environment (build 1.9.0-ea-b63) Java HotSpot(TM) 64-Bit Server VM (build 1.9.0-ea-b63, mixed mode) ~/java8/jdk/bin/java -showversion A java version "1.8.0_60-ea" Java(TM) SE Runtime Environment (build 1.8.0_60-ea-b14) Java HotSpot(TM) 64-Bit Server VM (build 25.60-b14, mixed mode)
18-05-2015