Schedule calculation resulted in duplicate adjusted dates ERROR

Just a quick post to see if anybody know this problem (it really look like a bug in the schedule building code).

I get a duplicate adjusment date only for this specific security,
if I change the start date just from 1 day, then it work fine.
ex: change start date from 2009-11-07 to 2009-11-06

If required I will post my complete test program.

Thanks

price ( "TEST CRASH ",
LocalDate.of(2020, 01, 21), // settlement
LocalDate.of(2009, 11, 7), // start date
LocalDate.of(2026, 05, 9), // maturity
0 /100, // Coupon
2.0 /100, // Yield
2
);

Servlet.service() for servlet [dispatcherServlet] in context with path threw exception [Request processing failed; nested exception is com.opengamma.strata.basics.schedule.ScheduleException: schedule calculation resulted in **duplicate adjusted dates [2009-11-09, 2009-11-09, 2010-05-10, 2010-11-09, 2011-05-09, 2011-11-09, 2012-05-09, 2012-11-09, 2013-05-09, 2013-11-12, 2014-05-09, 2014-11-10, 2015-05-11, 2015-11-09, 2016-05-09, 2016-11-09, 2017-05-09, 2017-11-09, 2018-05-09, 2018-11-09, 2019-05-09, 2019-11-12, 2020-05-11, 2020-11-09, 2021-05-10, 2021-11-09, 2022-05-09, 2022-11-09, 2023-05-09, 2023-11-09, 2024-05-09, 2024-11-12, 2025-05-09, 2025-11-10, 2026-05-11] from unadjusted dates [2009-11-07, 2009-11-09, 2010-05-09, 2010-11-09, 2011-05-09, 2011-11-09, 2012-05-09, 2012-11-09, 2013-05-09, 2013-11-09, 2014-05-09, 2014-11-09, 2015-05-09, 2015-11-09, 2016-05-09, 2016-11-09, 2017-05-09, 2017-11-09, 2018-05-09, 2018-11-09, 2019-05-09, 2019-11-09, 2020-05-09, 2020-11-09, 2021-05-09, 2021-11-09, 2022-05-09, 2022-11-09, 2023-05-09, 2023-11-09, 2024-05-09, 2024-11-09, 2025-05-09, 2025-11-09, 2026-05-09] using adjustment ‘Following using calendar CATO’] with root cause

Assuming that price() is your own method, somewhere inside it you are creating an instance of PeriodicSchedule. The start date is 7th Nov 2009 which is a Saturday, but rolls occur on the 9th. As a result the first unadjusted period from the 7th to the 9th folds into an empty period from the 9th to the 9th when Saturday is adjusted to a working day.

You have two choices:

  1. Adjust the start date to a working day before creating the schedule
  2. Use StubConvention.SMART_INITIAL, which handles cases like this automatically