PMO-2667: avoid class cast exception for patterns with zero rows
Merge remote-tracking branch 'origin/1.8.x' into 1.8.x