Ubayy wrote to Ubaydullah bin Abu Bakra, who was serving as a judge, saying, "Do not judge between two people while you are angry, for I heard the Messenger of Allah ﷺ say, 'A judge must not pass judgment between two people while he is angry.'"
حدثنا قتيبة حدثنا أبو عوانة عن عبد الملك بن عمير
كتب أبي إلى عبيد الله بن أبي بكرة وهو قاض أن لا تحكم بين اثنين وأنت غضبان فإني سمعت رسول الله ﷺ يقول لا يحكم الحاكم بين اثنين وهو غضبان
Sourced from Bukhari and Muslim.Muslim narrated it in the chapter on Judgments, in the section on the dislike of a judge issuing rulings while angry, hadith no. 1717, from Qutayba, and Bukhari, hadith no. 7158, from the hadith of Abdul-Malik bin Umayr, through this same chain.