BOSTON (Reuters) - A federal judge expressed outrage on Wednesday that a U.S. immigration agent came to court to arrest a Chinese woman just as she was sentenced to probation for using a fake passport and visa to take a graduate school entrance exam for someone else.

U.S. District Judge Indira Talwani in Boston said she was upset that U.S. Immigration and Customs Enforcement had come to the sentencing of Xinyan Wang, 27, with the purpose of taking her into custody, assuming she was not sentenced to prison.

She questioned why officials could not have reached out to her lawyer to allow Wang, who was not subject to an immigration hold, to turn herself in rather than take a step a longtime prosecutor handling her case said he not seen in three decades.

“I see no reason for places of redress and justice to become places that people are afraid to show up,” Talwani said.

The prosecutor, Assistant U.S. Attorney David Tobin, said: “Maybe I should have stopped it.” But following the hearing, an ICE agent escorted the former physics graduate student into a Ford Escape.

ICE did not respond to a request for comment.

Immigrant advocates have become increasingly alarmed about courthouse arrests under Republican President Donald Trump, which they say deter attendance at hearings and discourage witnesses from testifying about crimes.

The arrest took place after Talwani sentenced Wang to 12 months’ probation, rather than the three months in prison Tobin sought, after she pleaded guilty in January to charges she misused a passport and committed visa fraud.

Her plea centered on a single Graduate Record Exam, or GRE, that prosecutors said Wang took on Oct. 20 in Boston using a counterfeit Chinese passport and a bogus visa in another person’s name that contained photos that resembled her.

But authorities said in court papers that Wang had from July to August taken the GRE or the TOEFL, the English-language exam used to assess foreign applicants, on five prior occasions under assumed names.

She was previously a graduate student at Lehigh University in Pennsylvania, but after her adviser’s laboratory’s federal funding ran out, she enrolled in a nearby community college to keep her student visa, according to her lawyer, Syrie Fried.

Her arrest in November came after federal prosecutors in Boston announced a similar case in which Chinese students, unable to pass college entrance exams, hired impostors to take them in their place to apply for admission to U.S. schools.