Skip to content

NullPointerException on "new CalendarPanel()" #102

@tcrass

Description

@tcrass

Hi 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

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions