On the diameters of commuting graphs