The pump shaft is typically protected against water hammer by installing a surge suppressor or a water hammer arrestor. These devices help to absorb the sudden pressure surges that can occur when a pump is started or stopped abruptly, preventing damage to the pump shaft and other components of the system.