NullPointerException on "new CalendarPanel()"
See original GitHub issueHi there,
observerd in version 11.0.0:
When instancing a CalendarPanel using the parameter-less constructor
CalendarPanel calendarPanel = new CalendarPanel();
I get a NullPointerException:
java.lang.NullPointerException: null
at com.github.lgooddatepicker.components.CalendarPanel.<init>(CalendarPanel.java:253)
at com.github.lgooddatepicker.components.CalendarPanel.<init>(CalendarPanel.java:211)
...
It turns out that in the line in which the exception occurs…
displayedYearMonth = YearMonth.now(datePickerSettings.getClock());
…the datePickerSettings parameter is null (obviously, when looking at the calling site in line 211).
It’s only in line 294 of the constructor that the setSettings(datePickerSettings)
function gets called, which ensures that a default settings object is created in case the passed datePickerSettings are null.
I currently don’t have the possibility to fork the project and to work on this issue myself, but perhaps a simple solution would be to move the setSettings(datePickerSettings)
call right to the start of the constructor and to replace displayedYearMonth = YearMonth.now(datePickerSettings.getClock());
with displayedYearMonth = YearMonth.now(settings.getClock());
?
Cheers – Torsten
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (1 by maintainers)
Top GitHub Comments
@WiseEagleOwl, FYI, v11.0.2 demo is running successfully on double click under Mac OS Catalina, JDK 1.8. and Win 10 JDK 1.8. -Blake
@tcrass Thank you for confirming that
v11.0.2
works for you. Would you mind sharing which operating system (Windows, Mac, Linux, …) and Java version (8, 11, 14, …) your date picker application is running under? This information helps me keep track which combinations have already been tested and knowing the most popular setups of our user base would also be helpful.