New York Laws
Article 3 - Privilege From Arrest
24 - Privilege From Arrest of Officers of Courts of Record.

ยง 24. Privilege from arrest of officers of courts of record. An
officer of a court of record, appointed or elected pursuant to law, is
privileged from arrest, during the actual sitting, which he is required
to attend, of a term of the court of which he is an officer, and no
longer; but an attorney or counselor is not thus privileged, unless he
is employed in a cause, to be heard at that term.