More often than he'd like, Barney locks himself in a cell at the jail, which he dubs "The Rock." On this particular occasion, he manages to capture a couple of plainclothes detectives while allowing two real crooks to escape ("The Big House," Episode #95).
With Gomer as "blockhouse lookout" on the jail's roof, there's always hope that the crooks won't get completely away. Then again, maybe it's best to go find Andy.