Instead of doing this, just prevent users from creating a StorageLevel with offHeap = true and replication = 1. Add a check in the StorageLevel constructor and throw an exception if they make one. Otherwise nobody will understand why this code was added here.