To reproduce this error just perform a WMTS get capabilities request where group layers are included, a NULL pointer exception will be throw (full stack trace attached):
This happens because GeoServer doesn't returns an empty map (default behavior of the overridden method) but instead NULL when no legends are available. This typically happens for layer groups which don't have legends associated.
The line of code that does this:
GWC code can also be made more robust by ignoring NULL values.