After listening carefully to the two policemen, the judge had a problem: He did not believe them.

The officers, who had stopped a man in the Bronx and found a .22-caliber pistol in his fanny pack, testified that they had several reasons to search him: He was loitering, sweating nervously and had a bulge under his jacket.

But the judge, John E. Sprizzo of United States District Court in Manhattan, concluded that the police had simply reached into the pack without cause, found the gun, then “tailored” testimony to justify the illegal search. “You can’t have open season on searches,” said Judge Sprizzo, who refused to allow the gun as evidence, prompting prosecutors to drop the case last May.

Yet for all his disapproval of what the police had done, the judge said he hated to make negative rulings about officers’ credibility. “I don’t like to jeopardize their career and all the rest of it,” he said.

He need not have worried. The Police Department never learned of his criticism, and the officers  like many others whose word has been called into question  faced no disciplinary action or inquiry.