Fixed #5981 (FP: nullPointer on repeated switch)