OSHKOSH, Wis.  Defense Secretary Robert M. Gates is normally a mild-mannered man, at least in public, but he unleashed a torrent on Thursday about leaks during the investigation of the Foot Hood shootings and during President Obama’s deliberations on sending more American troops to Afghanistan.

First, on the president’s meetings on Afghanistan: “I have been appalled by the amount of leaking that has been going on in this process,” Mr. Gates told reporters on his plane en route to a Wisconsin factory that is churning out thousands of armored trucks for use by American troops in Afghanistan. He added that he thought “a lot of different places are leaking” and that he was “confident that the Department of Defense is one of them.”

Then he made a threat: “And frankly if I found out with high confidence anybody who was leaking in the Department of Defense, who that was, that would probably be a career ender.”

The defense secretary moved on to the investigation of Maj. Nidal Malik Hasan, who was charged in the deaths of 13 people on Nov. 5 at Fort Hood, Tex., and what Mr. Gates called “unconscionable” leaks from “everybody out there with their own little piece of the action.”