The homeless man was being “treated outrageously” but “reacted stupidly”, the judge says.